Hi,
Can any one help me in this case. I have two radio button columns in my grid. on select of one i need to clear another. Currently i have done that. But the problem is i have an event set for one radio button to clear another (when one is clicked) .Now , when i scroll out , go down and scroll in , the last selection is getting cleared.Basically the checked event for the radio button is getting called which clears of the other value.
My radio button declaration are : -
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="Clear"> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="Foreground" Value="Black"/> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <Border BorderBrush="Silver" BorderThickness="1"> <RadioButton IsChecked="{Binding DataItem.Clear, Mode=TwoWay}" IsEnabled="{Binding DataItem.EnableClearRadioButton,Mode=TwoWay}" Checked="Clear_Checked" Name="Clear" Padding="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> </RadioButton> </Border> </ControlTemplate> </Setter.Value> </Setter>
<Setter Property="Foreground" Value="Black"/> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderBrush" Value="Silver"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <Border BorderBrush="Silver" BorderThickness="1"> <RadioButton IsChecked="{Binding DataItem.Waive, Mode=TwoWay}" IsEnabled="{Binding DataItem.EnableWaiveRadioButton,Mode=TwoWay}" Padding="{TemplateBinding Padding}" Checked="Waive_Checked" Name="Waive" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> </RadioButton> </Border>
</ControlTemplate> </Setter.Value> </Setter> </Style>
<igDP:Field Name="Clear" Label="Clear" Width="70" DataType="{x:Type System:Boolean}" FixedLocation="FixedToNearEdge"> <igDP:Field.Settings> <igDP:FieldSettings CellWidth="70" LabelWidth="70" LabelTextAlignment="Center" AllowRecordFiltering="False" LabelTextTrimming="CharacterEllipsis" CellValuePresenterStyle="{StaticResource Clear}"> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Waive" Label="Waive" Width="70" DataType="{x:Type System:Boolean}" FixedLocation="FixedToNearEdge"> <igDP:Field.Settings> <igDP:FieldSettings CellWidth="70" LabelWidth="70" LabelTextAlignment="Center" AllowRecordFiltering="False" LabelTextTrimming="CharacterEllipsis" CellValuePresenterStyle="{StaticResource Waive}" /> </igDP:Field.Settings> </igDP:Field>
Now in the code behind,
i have the following code:
private void Waive_Checked(object args, RoutedEventArgs e) { var vm = this.DataContext as WIPManagementUtilityViewModel; if (vm != null && vm.ToggleChecked.CanExecute(null) && this.xamdgExceptions.ActiveRecord != null) { (this.xamdgExceptions.ActiveRecord as DataRecord).Cells["Clear"].Value = false; // vm.ToggleChecked.Execute(null);
} } private void Clear_Checked(object args, RoutedEventArgs e) { var vm = this.DataContext as WIPManagementUtilityViewModel; if (vm != null && vm.ToggleChecked.CanExecute(null) && this.xamdgExceptions.ActiveRecord != null) { (this.grid.ActiveRecord as DataRecord).Cells["Waive"].Value = false; //vm.ToggleChecked.Execute(null);
} }
Please help
Could you provide me with more details about your application, perhaps provide me with a sample that demonstrates the behavior?
Please include your xaml and viewmodel. It may be as simple as your viewmodel not implementing INotfyPropertyChanged. It does sound as if the values of the radio buttons aren't saved.
We also got the same type of issue.
Radio button got cleared as well as it got cleared while scrolling.
As specified, we have a Data template. with two radio button. and bound 'ischecked' property of radio button with the cell value presenter 'value' property.
But while scrolling or refreshing the values got cleared/Reset in radio button.
Could anybody please help me, to resolve this issue.
Thanks ,
Ravishankar
I hadn’t heard back from you and I was wondering if you had any further questions.
Without seeing your code this sounds like a focus issue. Sounds as if something is remaining in edit mode, perhaps the cells where the dropdowns are. In any case, these two links maybe helpful to you.
How to get StartEdit, EndEdit, CellUpdate event to fire with a custom CellValuePresenter
http://forums.infragistics.com/forums/p/37516/217714.aspx
Hosting WPF Controls in a xamDataGrid cell.
http://blogs.infragistics.com/blogs/andrew_smith/archive/2009/03/27/hosting-wpf-controls-in-a-xamdatagrid-cell.aspx
This blog by Alex and comments by Andrew may be what is going on in your sample. You mentioned a dropdown controls. Andrew mentions using EndEditMode to commit the change and take the control out of edit mode; thereby allowing the checkbox to receive focus and respond.
http://blogs.infragistics.com/blogs/alex_fidanov/archive/2010/03/12/commit-changes-when-the-value-of-editor-changes.aspx
If this isn’t the solution for you, I would recommend you’re giving me a sample to show he how you have implemented you edit button and drop down controls.
Forgot to mention :The edit button is outside the grid.