ListBox ctlList = sender as ListBox
;
UIElement elem = ( UIElement ) ctlList . InputHitTest ( e . GetPosition ( ctlList
) );
while ( elem != ctlList
)
{
if ( elem is ListBoxItem
)
{
rd = (( ListBoxItem ) elem ). Content as Record ;
// Handle the double click here
break
;
}
elem = ( UIElement ) VisualTreeHelper . GetParent ( elem
);
本文介绍了一种在WPF应用程序中处理ListBox项双击事件的方法。通过使用InputHitTest方法定位被点击的元素,并判断该元素是否为ListBoxItem类型来获取对应的数据上下文。这种方法可以有效地处理ListBox内的特定项被双击时的响应。
1万+

被折叠的 条评论
为什么被折叠?



