-2

I have a Window partial class (WPF Window) like:

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
   }   
}

In another assembly, I have logic which receives reference passed in above like this

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.
}

How do I get the actual class name for the passed in Window?

H.B.
  • 166,899
  • 29
  • 327
  • 400
pixel
  • 9,653
  • 16
  • 82
  • 149
  • The bigger question is why you would need a class name passed around. Maybe your are approaching your actual problem the wrong way. – H.B. Aug 09 '16 at 21:33

1 Answers1

1

Simply window.GetType().Name?

H.B.
  • 166,899
  • 29
  • 327
  • 400