Ribbonbar & RoutedCommand problem

Ribbon for WPF Forum

Posted 15 years ago by Arthur Damen
Version: 9.1.0505

I have a ribbon with several commands which enable/disable the state.
But all these elements are ribbonbuttons.

Now I created my own usercontrol where I also want to implement the command so that it can act the same as for example the ribbonbutton.

The next code is implemented in the usercontrol. Until now the command is not fired in the ribbon application. What am i missing/doing wrong here?

Dim MyCommand As Windows.Input.RoutedCommand = Nothing

    Public Property Command() As System.Windows.Input.ICommand
        On Error Resume Next
        Return MyCommand
      End Get
      Set(ByVal value As System.Windows.Input.ICommand)
        On Error Resume Next
        MyCommand = value
        AddHandler MyCommand.CanExecuteChanged, AddressOf CanExecuteChangedEvent
      End Set
    End Property
    Private Sub CanExecuteChangedEvent(ByVal sender As Object, ByVal e As System.EventArgs)
      On Error Resume Next
      If MyCommand.CanExecute(Nothing, Me) Then
        Me.IsEnabled = True
        Me.IsEnabled = False
      End If
    End Sub

Comments (2)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Arthur,

Just want to make sure I'm reading your question correctly... Are you asking how to make your UserControl enable/disable in response to a command being available?

What you have there is the same concept as what we do in our buttons, so it's hard to say what is wrong. What happens if you put your user control in a focus scope? Maybe since this is a general WPF question it would be better asked in the Microsoft WPF forum.

Actipro Software Support

Posted 15 years ago by Arthur Damen
Yes that is correct.
I want the usercontrol to have the same behaviour as the actipro ribbon buttons.
The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.