There is a certain user control. And he has a team. So, I want to make a button separately from this control that would execute a command that is in this control (it is added to the CommandBindings this control), but the command is inactive. Even the CanExecute procedure CanExecute not enter the program. Trying to do so

 <local:SlideListBox Grid.Row="1" x:Name="lbNot"> <ListBoxItem Content="qwe"/> <ListBoxItem Content="asd"/> <ListBoxItem Content="zxc"/> </local:SlideListBox> <Button Command="{Binding GoNextCommand, ElementName=lbNot}"/> 
  • one
    Your code is bound to the SlideListBox GoNextCommand property. Does he have such a property? - VladD
  • @VladD, Yes, there is. - iRumba

1 answer 1

The problem was in the registration team. The command is registered in the constructor of the SlideListBox class. It was like this

 CommandManager.RegisterClassCommandBinding(GetType(), goNextCommand); 

Did so

 CommandManager.RegisterClassCommandBinding(typeof(Window), goNextCommand); 

Now all the rules)

PS

goNextCommand in this case is not the command itself, but an instance of a CommandBinding created based on the command.