本文整理匯總了C#中System.Windows.Application.Windows屬性的典型用法代碼示例。如果您正苦於以下問題:C# Application.Windows屬性的具體用法?C# Application.Windows怎麽用?C# Application.Windows使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Windows.Application
的用法示例。
在下文中一共展示了Application.Windows屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1:
//引入命名空間
using System;
using System.Windows;
using System.Windows.Controls;
namespace CSharp
{
// Custom menu item that stores a reference to a window
public class WindowMenuItem : MenuItem
{
public Window Window = null;
}
}
示例2: MainWindow
//引入命名空間
using System;
using System.Windows;
using System.Windows.Controls;
namespace CSharp
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
示例3: MainWindow_Activated
void MainWindow_Activated(object sender, EventArgs e)
{
this.windowMenuItem.Items.Clear();
int windowCount = 0;
foreach (Window window in Application.Current.Windows)
{
++windowCount;
WindowMenuItem menuItem = new WindowMenuItem();
menuItem.Window = window;
menuItem.Header = "_" + windowCount.ToString() + " Window " + windowCount.ToString();
menuItem.Click += new RoutedEventHandler(menuItem_Click);
this.windowMenuItem.Items.Add(menuItem);
}
}
void menuItem_Click(object sender, RoutedEventArgs e)
{
WindowMenuItem menuItem = (WindowMenuItem)sender;
menuItem.Window.Activate();
}
}
}