It's not clear without seeing more code what's causing the properties not to update but there are a few issues that may be contributing.
The "isIndexFieldSelected" and "isCheckBoxEnabled" values look like field names rather than properties. If that's the case that would cause the problem since Binding requires properties but given the posted code it's not clear.
The way you're templating the menu items will cause two MenuItem objects to be created for each collection item. ContextMenu automatically generates a MenuItem instance for each item in the bound ItemsSource collection into which the DataTemplate for each item is injected. By declaring a MenuItem inside the ItemTemplate you are creating a MenuItem inside the Header section of each MenuItem in the ContextMenu. It may be the case that you are clicking on, and checking, the outer MenuItem which is not bound to the data. Try using these resources instead to both template and style the MenuItems that are generated for you:
<DataTemplate x:Key="SelectIndexFieldMenuTemplate">
<TextBlock Text="{Binding Path=IndexFieldName}"/>
</DataTemplate>
<Style x:Key="SelectIndexFieldMenuStyle" TargetType="{x:Type MenuItem}">
<Setter Property="IsCheckable" Value="True" />
<!--IsChecked is already TwoWay by default-->
<Setter Property="IsChecked" Value="{Binding Path=isIndexFieldSelected}" />
<Setter Property="IsEnabled" Value="{Binding Path=isCheckBoxEnabled}" />
</Style>
And use them like this:
<TabItem.ContextMenu>
<!--TwoWay doesn't ever do anything on ItemsSource-->
<ContextMenu Name="menu" ItemsSource="{Binding Path=FieldNameCollection}"
ItemContainerStyle="{StaticResource SelectIndexFieldMenuStyle}"
ItemTemplate="{StaticResource SelectIndexFieldMenuTemplate}"/>
</TabItem.ContextMenu>
It's also possible that your bound properties are not using INotifyPropertyChanged correctly, which would cause the UI to not update when the menu item checked state. It should look something like this:
private bool _isIndexFieldSelected;
public bool isIndexFieldSelected
{
get { return _isIndexFieldSelected; }
set
{
if (_isIndexFieldSelected == value)
return;
_isIndexFieldSelected = value;
NotifyPropertyChanged("isIndexFieldSelected");
}
}
public virtual void NotifyPropertyChanged(string propertyName)
{
PropertyChangedEventArgs ea = new PropertyChangedEventArgs(propertyName);
if (PropertyChanged != null)
PropertyChanged(this, ea);
}
public event PropertyChangedEventHandler PropertyChanged;
INotifyPropertyChangedinterface in your class? - decyclone