0

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>
barbara.post
  • 1,581
  • 16
  • 27
  • Your code does not work as it is. I get a message saying that *`'EditItem'` is not allowed for this view* when trying to enter edit mode. You'll get more help if you provide a working piece of code that users can simply copy and paste into Visual Studio. – Sheridan Dec 04 '13 at 13:35
  • Thank you. I just setup a stripped down project then. You can get it from my skydrive: https://skydrive.live.com/redir?resid=C7E7B3F3F8DB7864!2724&authkey=!AATEwpE8sPP5d7c&ithint=folder%2c.zip as an already compiled wpf .NET 4.5 app with source. In fact in the test project I allowed user to add new rows, while on real project it's done by capturing click on last line which has a dedicated template. So in test project, the is some glitch because image is initially shown but shouldn't. – barbara.post Dec 05 '13 at 12:27
  • Updated test projets with URL change: https://skydrive.live.com/redir?resid=C7E7B3F3F8DB7864%21250 In this version, no line addition is allowed and there are 3 lines to play with. Moreover, I use now a converter provided by MS, similar to the one I got from some blog post. The bug still persists, but I'm still unable to find out which particular click causes it. – barbara.post Dec 06 '13 at 11:47

1 Answers1

0

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

Or simply the groupname int the tw

Xarkam
  • 121
  • 7