Cannot select again radio in wpf datagrid (radio when editing, image when non editing)

126 views Asked by At

I have a wpf datagrid with cell editing/non editing templates. I alternatively show a radio button (edit mode) or an image (non edit mode). Image is visible when radio is checked (binded property is true). Radio are all grouped. Both editing/non-editing templates declare the radio so that radio group behavior works.

I have a really strange bug: I create several items and play with checking a radio. Sometimes I cannot check radio anymore, they go all unchecked. This is weird to reproduce but with 3 items rather than 2 the bug seemed to appear earlier.

What may I have done wrong ?

<DataGridTemplateColumn Header="Facturation" SortMemberPath="IsFacturation" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}">
    <DataGridTemplateColumn.CellEditingTemplate>
    <DataTemplate>
        <RadioButton GroupName="grpRadioButtonFacturationAddresses" 
        IsChecked="{Binding IsFacturation, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Visible"/>
    </DataTemplate>
    </DataGridTemplateColumn.CellEditingTemplate>
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <DockPanel>
            <RadioButton GroupName="grpRadioButtonFacturationAddresses" 
            IsChecked="{Binding IsFacturation, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Hidden"/>
            <Image Source="Resources/Images/Check-icon.png" Visibility="{Binding IsFacturation, Converter={StaticResource BoolToVisConverter}}"/>
            </DockPanel>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
1

There are 1 answers

1
Xarkam On BEST ANSWER

It's possible the two templates is cause of the bug ?

Or simply the groupname int the tw