我正在实施一个应用程序,如果我点击一个菜单项:
<MenuItem Name="menuAlgemeneGeg" Header="Algemene gegevens" Click="AlgemeneGegevensClick" />
方法是:
private void AlgemeneGegevensClick(object sender, RoutedEventArgs e)
{
ToetsBeheerViewModel vm = (ToetsBeheerViewModel)this.DataContext;
EditAlgemeneGegevens window = new EditAlgemeneGegevens(vm.Examination);
window.ShowDialog();
menuAlgemeneGeg.IsEnabled = false;
}
现在我想要的是,当你点击它时,菜单项被禁用。但是从用户关闭此窗口的那一刻起,它必须再次启用。我可以禁用menuitem但无法将其更改为启用它。 有人可以帮帮我吗?
答案 0 :(得分:1)
您可以处理窗口关闭事件..并在偶数处理程序中启用菜单
private void AlgemeneGegevensClick(object sender, RoutedEventArgs e)
{
ToetsBeheerViewModel vm = (ToetsBeheerViewModel)this.DataContext;
EditAlgemeneGegevens window = new EditAlgemeneGegevens(vm.Examination);
window.Closed += new EventHandler(Window_Closed);
window.ShowDialog();
menuAlgemeneGeg.IsEnabled = false;
}
void Window_Closed(object sender, EventArgs e)
{
menuAlgemeneGeg.IsEnabled = true;
}