Hi,
I have some problems in building a radGridView with radiobutton inside in XAML. You can see the attached image to have an idea of what I'm doing.
I have a grid that contains a list of "container" (they could be one, 2 or more). So every row has a plate(with an id) and 2 radio button (ground - Upper). I retrieve the value of these radiobutton from the DB. Radio button Ground is selected when the variable IsUtiInDoubleStakerHold == 0. If IsUtiInDoubleStakerHold == 1radiobutton Upper has to be selected; if radiobutton Ground is selected, radiobutton Upper cannot be selected and vice versa. For every row I need to select a radio button, and then I have to save the value eventually modified. How can I do this? Actually with this code if I do a choice of a value in the first row, then when I make a selection on the second row, I lost the value of the radiobutton selected in the first row (I can't see anymore the selection done before).
How can i solve this problem?
After that, how can I maintain the value changed in every row? (I hope to save everything in the object public ObservableCollection<ItuForYard> ItusSameGroupList)
The xaml RadGridView is defined in this way:
01.<StackPanel Grid.Row="3" >02.<telerik:RadGridView03. SelectedItem="{Binding SelectedItu, Mode=TwoWay}"04. ShowColumnSortIndexes="False"05. ItemsSource="{Binding ItusSameGroupList, Mode=TwoWay}" 06. Visibility="{Binding GridItusSameGroupVisibility}"07. Margin="0,10,0,10" >08. <telerik:RadGridView.Columns>09. <telerik:GridViewDataColumn t:I18N.Translate="ITU Id"DataMemberBinding="{Binding UtiId}" Width="0" IsVisible="False" />10. <telerik:GridViewDataColumn t:I18N.Translate="ITU Plate"DataMemberBinding="{Binding UtiPlate}" Width="4*" />11. <telerik:GridViewDataColumn t:I18N.Translate="Ground" Width="3*">12. <telerik:GridViewDataColumn.CellTemplate>13. <DataTemplate>14. <RadioButton GroupName="GroundUpper" Content="{Binding RadioButtonGround}" HorizontalAlignment="Center"IsChecked="{Binding RadioButtonGroundIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsGroundUpperRadioButtonEnabled}" />18. </DataTemplate>19. </telerik:GridViewDataColumn.CellTemplate>20. </telerik:GridViewDataColumn>21. <telerik:GridViewDataColumn t:I18N.Translate="Upper"DataMemberBinding="{Binding IsUtiInDoubleStakerHold}" Width="3*">22. <telerik:GridViewDataColumn.CellTemplate>23. <DataTemplate>24. <RadioButton GroupName="GroundUpper" Content="{Binding RadioButtonUpper}"25. HorizontalAlignment="Center"26. IsChecked="{Binding RadioButtonUpperIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"27. IsEnabled="{Binding IsGroundUpperRadioButtonEnabled}" />28. </DataTemplate>29. </telerik:GridViewDataColumn.CellTemplate>30. </telerik:GridViewDataColumn>31. </telerik:RadGridView.Columns>32.</telerik:RadGridView>33.</StackPanel>
In the cs file:
public bool IsGroundUpperRadioButtonEnabled => SelectedItu != null &&
SelectedItu.IsUtiInDoubleStakerHold != 2;
public Visibility GridItusSameGroupVisibility => SelectedItu != null ? Visibility.Visible : Visibility.Collapsed;
public bool RadioButtonGroundIsChecked => SelectedItu != null && SelectedItu.IsUtiInDoubleStakerHold == 0;
public bool RadioButtonUpperIsChecked => SelectedItu != null && SelectedItu.IsUtiInDoubleStakerHold == 1;
public ObservableCollection<ItuForYard> ItusSameGroupList { get; set; } = new ObservableCollection<ItuForYard>();
Then I populate the list of container with the result from the DB
ItusSameGroupList = new ObservableCollection<ItuForYard>(ituResponse.Result);