WPF toolkit DataGridCheckBox Column check/uncheck events

Mar 12, 2009 at 6:35 AM
Edited Mar 12, 2009 at 6:39 AM

I am using datagrid control of wpf toolkit. i have checkbox column. I want to track the check and uncheck event of that checkbox column, but m not sure which event to attach to that column, and based on the status of check box i want give style to other column in my datagrid row.

here is the XAML markup:




<Style x:Key="textstyle" TargetType="TextBlock"> 
<Setter Property="FontWeight" Value="bold"> 
<Setter Property="TextDecorations" Value="StrikeThrough"></Setter>

<toolkit:DataGrid x:Name="dglist" CanUserAddRows="False" Grid.Row="1" Grid.ColumnSpan="2" Background="#FFE5E5E5" SelectionMode="Single" CanUserResizeRows="False" AutoGenerateColumns="False"> <toolkit:DataGrid.AlternatingRowBackground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFB5ABE4" Offset="0"/> 
<GradientStop Color="#FFD3CFE5" Offset="0.976"/>
<toolkit:DataGridCheckBoxColumn x:Name="status" Header="Done" Binding="{Binding status}"></toolkit:DataGridCheckBoxColumn>
<toolkit:DataGridTextColumn Header="Task" Binding ="{Binding task}">
<toolkit:DataGridTextColumn Header="Due Date" Binding="{Binding date}"/>

Could you please suggest me how to do it.



Mar 12, 2009 at 11:40 PM

I see that you are binding a 'status' property to your checkbox. What you can do is - create a CellStyle for the other column and in that style bind what ever property you want to bind to the 'status' property with appropriate converter. Following should server as an example for Background property...

<toolkit:DataGridCheckBoxColumn x:Name="status" Header="Done" Binding="{Binding status}"></toolkit:DataGridCheckBoxColumn>
<toolkit:DataGridTextColumn Header="Task" Binding ="{Binding task}"> 
        <Style TargetType="{x:Type toolkit:DataGridCell}">
            <Setter Property="Background" Value="{Binding status, Converter={StaticResource MyStatusToBackgroundConverter}}"/>

Or you can use an EventSetter in EditingElementStyle of CheckBoxColumn and execute what ever code you want.
Mar 24, 2009 at 7:04 AM
M still not able to do it. Can you please send me some code snippet for any of the above solution u have mentioned.. i tried to search it on net also but no luck.