Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

listview - Shift-click and ctrl-click also registering normal left click in WPF

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...