从Window Reference获取窗口的ClassName

时间:2016-08-09 21:30:55

标签: wpf window classname

我有一个Window分部类(WPF窗口),如:

public partial class MyWindow : Window
{
   // this is just a WPF window

   // I have in XAML Closing event like Closing="Window_Closing"
   // and here is the event definition
   public void Window_Closing(object sender, CancelEventArgs e)
   {
      SaveWindowState(this); // just passes reference to itself
   }   
}

在另一个程序集中,我有逻辑接收上面传递的引用,如此

public static void SaveWindowState(Window window)
{
    // Since I can call this from many windows, I need a way to get
    // the class name of my window in here.  Basically, for MyWindow
    // above, I need to get "MyWindow" and for other windows, I need
    // to get thier class name from the passed in "window" parameter.
}

如何获取传入窗口的实际类名?

1 个答案:

答案 0 :(得分:1)

只需Wearable.MessageApi.addListener(...