以下是我的代码。
public class baseMenuItem : MenuItem
{
public baseMenuItem()
{
this.Click += baseMenuItem_Click;
}
void baseMenuItem_Click(object sender, RoutedEventArgs e)
{
//When user click the menu, I will need to new a window which type is assigned from AssignHandleWindow<T>()
}
public void AssignHandleWindow<T>() where T : baseWindow
{
//Can I save <T> into somewhere for later Click-event using?
//How do I do that?
}
}
我不确定这是否可行,但我的应用程序中可能还有 40 个 menuItems,我不想为每个人写点击事件来打开窗口,知道吗?
谢谢。