WPF Routed Command with Bindings per-Tab

前端 未结 3 2056
别跟我提以往
别跟我提以往 2021-01-16 07:28

I intended to disable and enable the Buttons outside the TabControl, just like those inside the TabItem when the current tab is changed. But the CommandBindings of the TabIt

3条回答
  •  佛祖请我去吃肉
    2021-01-16 08:20

    Your don't have any code that could disable buttons. You can do it in several ways:

    1. Define CanExecute event handler.

    
    

    Code behind:

    private void MyCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
    {
        e.CanExecute = tabItem1.IsSelected;
    }
    

    2. Bind button IsEnabled property to tab item IsSelected property

提交回复
热议问题