Since you have bound the SelectedItem I am not sure what you are going to accomplish. This variable will change upon each selection.
Capturing selection change / click inside WPF ListView / MVVM
Hi, I am trying to get the selection change inside a WPF ListView using Interaction.Triggers. I have only included just the basic XAML for now. But I am getting error in XAML as well as in code.
XAML : The name interaction does not exist in namepace ......interactivity
build: error MC3074: The tag 'Interaction.Triggers' does not exist in XML namespace 'http://schemas.microsoft.com/expression/2010/interactivity'.
Below is the code in XAML
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
....
...
<ListView x:Name="lstItems" Grid.Row="3" FontSize="15" ItemsSource="{Binding Path=TaskList}" SelectedItem="{Binding Path=SelectedTask}" Foreground="DarkGreen" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<!--
<i:InvokeCommandAction
Command="{Binding DataContext.SelectItemRelayCommand,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ItemsControl}}}"
CommandParameter="{Binding Id}">
</i:InvokeCommandAction>
-->
</i:EventTrigger>
</i:Interaction.Triggers>
</ListView>
Could someone please help?
2 answers
Sort by: Most helpful
-
-
DaisyTian-1203 11,626 Reputation points
2020-09-21T03:09:12.147+00:00 You can add Microsoft.Xaml.Behaviors.Wpf in your project Nuget instead of adding dlls in the References
Step 1 : Right click your project and select Manage Nuget packages.. in the popup window.
Step 2: Search and install Microsoft.Xaml.Behaviors.Wpf.
Step 3: Replace
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
withxmlns:i="http://schemas.microsoft.com/xaml/behaviors"
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.