【发布时间】:2016-12-16 02:12:10
【问题描述】:
我有一个 Window 部分类(WPF Window),例如:
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.
}
如何获取传入的 Window 的实际类名?
【问题讨论】:
-
更大的问题是为什么你需要传递一个类名。也许您以错误的方式处理您的实际问题。