tags:

views:

12

answers:

1

Hi,

In WPF, i have raised previewMouseLeftButton down for tabItem.I want this event to raise when tabitem's header is clcked. Tab item's content is textbox and button, But whenever i click on textbox or button, tabitem's previewmouseleftbuttondwn is raised. How can it be avoided?,Please help

Thanks,

A: 

This is due to tunneling in Wpf, you can stop tunneling by handling this event at root and in the handler write:

e.Handled = true;

then it will not tunnel down.

And then if you want to handle it for your textbox or button use AddHandler method to assign handler to the event instead of using normal += format.

button.AddHandler(Button.ClickEvent, new RoutedEventHandler(OnbuttonClick));

Check this for details: http://msdn.microsoft.com/en-us/library/ms742806.aspx#event%5Fhanding

viky