Well, to add a MenuItem, you will need something in this direction:
var menuItem = new MenuItem() { Header = "Menu Name", Name = "Identifier", IsCheckable = true, IsChecked = visible };
menuItem.Click += new RoutedEventHandler(contextMenu_onClick);
int position = contextMenu.Items.Add(menuItem);
(but you probably already got this).
You will need some way to bind the menu item to a property - but without viewing your application, I cannot offer a better way. There is a Tag property that stores the object; Uid property that stores the string; Name property, which also saves the string.
While:
menuItem.Visibility = Visibility.Visible;
and
menuItem.Visibility = Visibility.Collapsed;
should switch the visibility of the element.
: Collapsed , - . ( Botz3000 )
, , , /, , . , :
menuItem.Visibility = menuItem.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;