I have Infragistics NetAdvantage 10.1. I want to use the XamWebMenu like a Toolbar. So I have this simple xaml
<igMenu:XamWebMenu x:Name="MainMenu" MenuOrientation="Horizontal" VerticalAlignment="Top" Height="28" HorizontalAlignment="Stretch"> <igMenu:XamWebMenuItem Header="New" x:Name="btnNew" Click="btnNew_Click"> <igMenu:XamWebMenuItem.Icon> <Image Source="/Infragistics_10_1_Playground;component/Images/info.png" /> </igMenu:XamWebMenuItem.Icon> </igMenu:XamWebMenuItem> <igMenu:XamWebMenuItem Header="Print" x:Name="btnPrint"> <igMenu:XamWebMenuItem.Icon> <Image Source="/Infragistics_10_1_Playground;component/Images/fail.png" /> </igMenu:XamWebMenuItem.Icon> </igMenu:XamWebMenuItem> </igMenu:XamWebMenu>
How can I make the WebMenu behave like a toolbar. Meaning, when you click the XamWebMenuItem it should act like a button. When pressed, the item should change in some manner to inform the user that they selected the item and then immediately after the button should appear unselected. I don't care if its styling or code-behind, how can I make it behave like a toolbar button?
In Code-behind I wanted to set "IsHighlighted" to false but of course its readonly. Is there another way to set this property in code-behind? I tried toggling IsEnabled (i.e setting to false then back to true) but that didn't work either.
Any help would be greatly appreciated.
Hi
The easiest way to do that is to handle MouseLeftButtonDown and MouseLeftButtonDown events. In its handler you just change MenuItem’s Bachground property.
In XAML
<igMenu:XamMenuItem Header="item2" MouseLeftButtonDown="XamMenuItem_MouseLeftButtonDown" MouseLeftButtonDown="XamMenuItem_MouseLeftButtonUp"/>
In code behind.
private void XamMenuItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
XamMenuItem menuItem = sender as XamMenuItem;
VisualStateManager.GoToState(menuItem, "Normal", false);
menuItem.Background = new SolidColorBrush(Colors.Blue);
}
private void XamMenuItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
VisualStateManager.GoToState(menuItem, "MouseOver", false);
menuItem.Background = new SolidColorBrush(Colors.Transparent);