Ribbonbar & RoutedCommand problem

Ribbon for WPF Forum

Posted 10 years ago by Arthur Damen
Version: 9.1.0505
Avatar
Hi,

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
      Get
        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
      Else
        Me.IsEnabled = False
      End If
    End Sub

Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 10 years ago by Arthur Damen
Avatar
Yes that is correct.
I want the usercontrol to have the same behaviour as the actipro ribbon buttons.
The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.