This question is locked. New answers and comments are not allowed.
Hi..
i develped a control using IsChecked dependency property.
the proble is that , it gets incorrect data. why?
==========================================xaml==================================
<Grid Style="{StaticResource GridStyle}">
<Grid.Resources>
<viewModel:ApplicantIDDetailViewModel x:Key="ApplicantIDDetail" />
<converter:StringToBooleanConverter x:Key="StringToCharConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="3*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ctrl:ValidationMessages x:Name="validator" Grid.Row="0" />
<ns:GridView x:Name="gvIDDetail" Style="{StaticResource GridViewCommonStyle}" Grid.Row="1">
<ns:GridView.Columns>
<ns:GridViewMaskedTextBoxColumn Header="ID Number" Width="0.2*" MinWidth="120" IsFilterable="False"
Background="Bisque"
MaskType="None" DataMemberBinding="{Binding IDTYPENBR, Mode=TwoWay}" />
<ns:GridViewRadioButtonColumn ColumnGroupName="DefaultGroup" Header="Default" Width="60" MinWidth="60" IsFilterable="False"
IsChecked="{Binding DEFAULTIND,Mode = TwoWay}"
/>
</ns:GridView.Columns>
</ns:GridView>
</Grid>
=================================================ISingleSelectable.cs ===================
public class ISingleSelectable : GridViewBoundColumnBase
{
}
============================================GridViewRadioButtonColumn.cs===============
public class GridViewRadioButtonColumn : ISingleSelectable
{
public bool IsChecked
{
get { return (bool)GetValue(IsCheckedProperty); }
set { SetValue(IsCheckedProperty, value); }
}
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register("IsChecked", typeof(bool), typeof(GridViewRadioButtonColumn),
new PropertyMetadata(new PropertyChangedCallback(IsCheckedPropertyChanged)));
static void IsCheckedPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
GridViewRadioButtonColumn instance = (GridViewRadioButtonColumn)o;
instance.IsChecked = (bool)e.NewValue;
if (instance.RadioButton != null)
{
instance.RadioButton.IsChecked = instance.IsChecked;
}
}
public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
{
radioButton = cell.Content as SystemControls.RadioButton;
if (radioButton == null)
{
radioButton = new SystemControls.RadioButton();
radioButton.GroupName = "default";
radioButton.IsChecked = IsChecked;
}
return radioButton;
}
SystemControls.RadioButton radioButton;
public SystemControls.RadioButton RadioButton
{
get
{
return radioButton;
}
}
}