I have a ListView in WPF with a list of some items. When left clicking an item some action should occur, lets say a pop up window displays. In addition, it should be possible to ctrl-click and shift-click to select multiple items. This is possible now, but what happens in addition is that these clicks registers as regular left clicks so that the pop up windows display for every single item that I ctrl-click or shift-click. How can I make it so that the pop up windows only displays on an unmodified left click?
Here is my ListView code:
<ListView Grid.Row="0" x:Name="ItemList"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Visible"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True"
ItemsSource="{Binding FiltereItems}"
SelectionMode="Extended">
<ListView.Resources>
<Style TargetType="{x:Type ListViewItem}" >
<Setter Property="IsSelected" Value="{Binding Selected, Mode=TwoWay}"/>
</Style>
</ListView.Resources>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.View>
<GridView>
<GridViewColumn Width="75" Header="Id">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" FontWeight="Bold" Text="{Binding Id}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="150" Header="Element" DisplayMemberBinding="{Binding ElementReference}"/>
<GridViewColumn Width="150" Header="Error message" DisplayMemberBinding="{Binding Description}"/>
</GridView>
</ListView.View>
</ListView>
question from:
https://stackoverflow.com/questions/66059657/shift-click-and-ctrl-click-also-registering-normal-left-click-in-wpf 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…