Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1085
radio button selection inside xamdatagrid gets cleared
posted

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