Approved
Last Updated: 03 Jan 2017 20:53 by ADMIN
ADMIN
Milena
Created on: 25 Feb 2015 09:38
Category: TabControl
Type: Bug Report
1
TabControl: TabControl: MouseLeftButtonUp selects the item from the DropDownMenu
Workaround:
Use the PreviewMouseLeftButtonUp and PreviewMouseLeftButtonDown events of the DropDownMenuItem. Handle the first event and invoke DropDownMenuItem.MouseLeftButtonUpEvent in the second in order to workaround the MouseLeftButtonUp event fired from the DropDownMenuButton and to call the logic for selecting the tabitem only when the dropdown menuitem is clicked (not just hovered). 

<Style TargetType="telerikTabControl:DropDownMenuItem">		
        <EventSetter Event="PreviewMouseLeftButtonUp" Handler="DropDownMenuItem_PreviewMouseLeftButtonUp" />
        <EventSetter Event="PreviewMouseLeftButtonDown" Handler="DropDownMenuItem_PreviewMouseLeftButtonDown" />
</Style>

private void DropDownMenuItem_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{		
		e.Handled = true;
}

private void DropDownMenuItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
	var item = (sender as DropDownMenuItem);
	MouseButtonEventArgs mouseEventArgs = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left);
	mouseEventArgs.RoutedEvent = DropDownMenuItem.MouseLeftButtonUpEvent;
	item.RaiseEvent(mouseEventArgs);
}
0 comments