I have created a side menu in a WPF. Here is the xaml:
<Rectangle VerticalAlignment="Stretch" Width="1" Margin="2" Stroke="Black" />
<MenuItem Header="Remove Headers" Click="MenuItem_Click_RH" />
<MenuItem Header="Get Headers" Click="MenuItem_Click_GH" />
<MenuItem Header="Count Delimiters" Click="MenuItem_Click_CNTD" />
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<MenuItem Header="Close" Click="MenuItem_Click_Close" />
</Menu>
Here is my click code:
private void MenuItem_Click_CNTD(object sender, RoutedEventArgs e)
{
//*** Count Delimiters Menu Click ***
// ... Cast sender object.
System.Windows.Controls.MenuItem item = sender as System.Windows.Controls.MenuItem;
// ... Change Title of this window.
Title = "Process " + item.Header + " Files";
lblDCTitle.Content = "Process to get mumber of delimiters in a large file.";
grdHeaderRows.Visibility = Visibility.Hidden;
mnuSideMenu.Height = 360;
grdMain.Height = 360;
grdDelimiterCount.Height = 400;
grdDelimiterCount.Visibility = Visibility.Visible;
}
This all works fine but I would like to highlight the menu item that was clicked. I cannot find code to do this. Anyone have any ideas?
Thank you
Thanks #Alexandru Turcan for your suggestion. I was able to do it this way, I do not have many menu items and this works perfectly for me. I put this code in each of my menu_click routines.
miRH.Background = SystemColors.ControlDarkBrush;
miGH.Background = new SolidColorBrush(Color.FromArgb(100, 232, 249, 246));
miCD.Background = new SolidColorBrush(Color.FromArgb(100, 232, 249, 246));