Hello
Is there a way I can set up a mouse click event for the tabs on the TabGroupPane which will execute a code behind.
Thanks
Manoj Reddy Palle
Hello,
I have been looking into your issue and I can suggest you use an event setter. If you want to read detailed information about event setters, you can open the following MSDN link :
http://msdn.microsoft.com/en-us/library/system.windows.eventsetter.aspx
As you can see an event setter is used in a style definition. In our case the target type of the style is ‘PaneTabItem’ and the most appropriate event I could think of is ‘PreviewMouseLeftButtonDown’. You can also use the MouseLeftButtonUp , MouseDown, MouseRightButtonDown or another one that best meets your needs.
For example :
<Style TargetType="{x:Type igDock:PaneTabItem}">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="MyHandler"/>
</Style>
void MyHandler(object sender, MouseButtonEventArgs e)
{
// here you can add the desired functionality that will be executed when you click a tab
}
If you require any further assistance please do not hesitate to ask.
One question regarding this solution. I'm trying to cancel a tab switch. So inside the "MyHandler" I'm doing a
var Result = MessageBox.Show("Save changes?", "Save changes", MessageBoxButton.YesNoCancel
if(Result == MessageBoxResult.Cancel)
e.Handled = true;
else
e.Handled = false;
The problem is that e.Handled = false is executed BUT the tab doesn't change anymore. Any idea what's up?