Intellisense doesn't work for MVVM light toolkit

前端 未结 1 659
旧时难觅i
旧时难觅i 2021-01-21 18:18

I began to use MVVM pattern yesterday.But for working with events i needed to install MVVM light toolkit.I did that,and added library to references.At UserControl i announced th

相关标签:
1条回答
  • 2021-01-21 18:49

    You have to use it like this ..

    Namespace to add :
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <mvvm:EventToCommand Command="{Binding Path=UserControlLoadedCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers> 
    

    Dont forget to add a reference to System.Windows.Interactivity to your project

    You need To Use PassEventArgsToCommand="True" in

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <mvvm:EventToCommand Command="{Binding Path=UserControlLoadedCommand}" PassEventArgsToCommand="True" />
        </i:EventTrigger>
    </i:Interaction.Triggers> 
    

    And then you can get that at ViewModel ..... you Might Need to use Generic RelayCommand as

    RelayCommand<KeyEventArgs> myCommand= new RelayCommand<KeyEventArgs>(Execute,CanExecute)
    
    0 讨论(0)
提交回复
热议问题