public class baseMenuItem : MenuItem
{
Type handleWindowType;
public baseMenuItem()
{
this.Click += baseMenuItem_Click;
}
void baseMenuItem_Click(object sender, RoutedEventArgs e)
{
if (null != handleWindowType)
{
baseWindow win = (baseWindow)Activator.CreateInstance(handleWindowType);
win.Show();
}
e.Handled = true; //To prevent routed event triggered
}
public void AssignHandleWindow<T>() where T : baseWindow
{
handleWindowType = typeof(T);
}
}
沒有留言:
張貼留言