Question

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>
Was it helpful?

Solution

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

Or simply the groupname int the tw

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top