如何实现ListBox的鼠标双击?

问题描述 投票:0回答:1
c# wpf xaml
1个回答
0
投票

处理程序应附加在 ItemContainerStyle 中:

<ListBox ...>
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <EventSetter Event="MouseDoubleClick"
                         Handler="ListBoxItem_MouseDoubleClick"/>
        </Style>
    </ListBox.ItemContainerStyle>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}"/>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
© www.soinside.com 2019 - 2024. All rights reserved.