I created a ListView that shows some element names in a column and in a second column I want to select one item using a RadioButton. However the binding of the RadioButtons IsChecked property does not seem to work, the IsMaster property of the item in the collection is not changed.
I simplified my classes a bit. This is the struct used for the collection:
public struct SomeData
{
public string Name
{
get;
set;
}
public bool IsMaster
{
get;
set;
}
}
The ViewModel contains the collection:
public ObservableCollection<SomeData> DataCollection
{
get;
set;
}
The View contains the DateTemplates and die ListView:
<DataTemplate x:Key="NameTemplate">
<TextBlock>
<TextBlock.Text>
<Binding Path="Name"/>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
<DataTemplate x:Key="IsMasterTemplate">
<RadioButton GroupName="MainGroup">
<RadioButton.IsChecked>
<Binding Path="IsMaster" Mode="TwoWay" NotifyOnTargetUpdated="True" />
</RadioButton.IsChecked>
</RadioButton>
</DataTemplate>
<ListView ItemsSource="{styleTemplates:WpfBinding Path=DataCollection}" >
<ListView.View>
<GridView>
<GridViewColumn Header="Name" Width="200" CellTemplate="{StaticResource NameTemplate}" />
<GridViewColumn Header="Is Master" Width="140" CellTemplate="{StaticResource IsMasterTemplate}" />
</GridView>
</ListView.View>
</ListView>
What did I miss ?