This question is locked. New answers and comments are not allowed.
Hi,
I can't get the contextmenu to Reevaluate canExecute.
What is the best practise to get contextMenu to evaluate CanExecute every time it's open. (So it's enable when it's supposed to be enabled...)
MainPage.xaml
MainPage.xaml.cs
ViewModel.cs
I can't get the contextmenu to Reevaluate canExecute.
What is the best practise to get contextMenu to evaluate CanExecute every time it's open. (So it's enable when it's supposed to be enabled...)
MainPage.xaml
<Grid x:Name="LayoutRoot"> <TextBlock Text="RightClick me"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="ContextMenu" GotFocus="ContextMenu_GotFocus"> <telerik:RadMenuItem Header="Remove" Name="MnuRemove" Command="{Binding Remove}" CommandParameter="{Binding guid}" /> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </TextBlock></Grid>private void ContextMenu_GotFocus(object sender, RoutedEventArgs e) { CommandManager.InvalidateRequerySuggested(); }public DelegateCommand Remove { get; private set; } public Viewmodel() { this.Remove = new DelegateCommand(OnRemove, CanRemove); } private bool CanRemove(object obj) { bool cr = ((DateTime.Now.Second % 2) == 0); Debug.WriteLine(cr); return cr; } private void OnRemove(object parameter) { MessageBox.Show("Remove"); }