- A+
所属分类:.NET技术
1.New Wpf project;
2.Add New Wpf Window named SubWindow;
3.Set global vairable via App.Current.Properties[objKey]=objValue in MainWindow constructor.
public MainWindow() { InitializeComponent(); App.Current.Properties["CurrentId"] = "FB8EA0F0-CC46-4A7F-8E95-697B04F543D1"; }
4.Invoke and call the assigned global variable in sub window constructor
public SubWindow() { InitializeComponent(); MessageBox.Show(App.Current.Properties["CurrentId"].ToString()); }
5.In the MainWindow page,click the button and show the result.
private void Button_Click(object sender, RoutedEventArgs e) { SubWindow subWin = new SubWindow(); subWin.Show(); }