开发者

Why does SelectionChanged bubble from ComboBox to parent TabControl?

After experiencing it myself, I did a quick search and found that SelectionChanged will bubble from a ComboBox to a parent TabControl if left unhandled in:

In C# WPF, why is my TabControl's Sel开发者_高级运维ectionChanged event firing too often?

My question is why? What is the reasoning behind this? I feel like I'm missing something pretty important about WPF and events.


Most events in WPF will bubble (or tunnel) until someone sets Handled=true on the event args. The upside of this is that suppose you had multiple comboboxes within a single tab control - you could in a single place handle changes to all of those boxes. You can do this in addition to handling the event seperately on each ComboBox or also handling a consolidated event even higher up in the tree like monitoring all ComboBoxes within the entire window.

This is what WPF calls "routed events". For a good intro to the topic, check out http://msdn.microsoft.com/en-us/library/ms742806.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜