我有一个包含许多项目的 WPF 列表框,因此会显示一个滚动条。我想为用户点击项目而不是滚动条添加事件处理程序。我该怎么做?
最佳答案
您可以使用 ItemContainerStyle
为使用 EventSetter
的项目设置点击事件的处理程序
<ListBox>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<EventSetter Event="Click" Handler="myHandler"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
关于c# - 在 WPF 中,如何区分列表框项目或滚动条中的鼠标点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45496358/