michaelscodingspot / WPF_MVVMC

A WPF framework for navigation between pages with MVC-like pattern
MIT License
64 stars 18 forks source link

navigate from Inputbinding #1

Closed ghost1372 closed 5 years ago

ghost1372 commented 5 years ago

hi i need navigate when user click on Expander Menu But this control does not have the Command property so After some searching I found the following code:

<MyExpander Content="new">
    <MyExpander.InputBindings>
        <MouseBinding Gesture="LeftClick" 
                     Command="{mvvmc:NavigateCommand ControllerID='MainOperation',Action='myDashboard'}"
                      CommandParameter="smth"/>
    </MyExpander.InputBindings>
</MyExpander>

But the command is not executed

michaelscodingspot commented 5 years ago

Hi,

You can try to use with the System.Windows.Interactivity.WPF NuGet like this:

// namespace:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
// ....

<MyExpander Content="new">
  <i:Interaction.Triggers>
    <i:EventTrigger EventName="Expanded" >
      <i:InvokeCommandAction 
        Command="{mvvmc:NavigateCommand ControllerID='MainOperation', Action='myDashboard'}"
        CommandParameter="smth" />
    </i:EventTrigger>
    <i:EventTrigger EventName="Collapsed" >
      <i:InvokeCommandAction 
        Command="{mvvmc:NavigateCommand ControllerID='MainOperation', Action='myDashboard'}"
        CommandParameter="smth" />
    </i:EventTrigger>
  </i:Interaction.Triggers>
</MyExpander>
ghost1372 commented 5 years ago

tnx