在选择更改的事件上禁用事件冒泡

编程入门 行业动态 更新时间:2024-10-26 20:34:24
本文介绍了在选择更改的事件上禁用事件冒泡-WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在列表视图中有一个列表框.在他们两个我都有selectionchanged事件.当我触发子控件事件时,父控件会自动触发.我需要停止这种行为. 有什么提示吗? 谢谢!

I have a listbox inside a listview. on Both of them I have selectionchanged event. When I fire child control event parent control fires automatically. I need to stop this behaviour. Any hints? Thanks!

<ListView Name="listView1" ItemContainerStyle="{StaticResource RowStyle}" AlternationCount="2" SelectionChanged="listViewTask_SelectionChanged"> <ListView.View> <GridView> <GridViewColumn Width="150"> <GridViewColumnHeader Name="gridViewColumnHeader1" Click="SortClick" Tag="Style" Content="Style" ToolTip="Click to Sort Style"/> <GridViewColumn.CellTemplate> <DataTemplate> <ListBox ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" BorderBrush="White" SelectionChanged="listBox_SelectionChanged" Name="listbox" ItemsSource="{Binding Text}" Style="{StaticResource Textblockstyle}" ToolTipService.ShowDuration="360000000">

-

推荐答案

您可以在选择更改事件中使用OriginalSource属性

you can use the OriginalSource property in the selection changes event

if( ((ListView)e.OriginalSource).Name.Equals("name of the listview")) { // handle the event here... }

更多推荐

在选择更改的事件上禁用事件冒泡

本文发布于:2023-11-10 22:57:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576691.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!