Search code examples
c#wpfivalueconverter

how to make checkbox check and uncheck wpf


I have taken checkbox in datagrid

<DataTemplate>
  <CheckBox x:Name="chkActive" IsChecked="{Binding Active, Mode=TwoWay}" 
    Style="{StaticResource checkboxStyleNormal}" IsEnabled="True"/>
 </DataTemplate>

and binding the datagrid

 datagrid1.ItemSource = dtData.DefaultView;

In datatable I am getting Active as 0 and 1, I want to show my check box checked when Active = 0

Grid is binding but I am unable to bind checkbox.

Some one please tell me how to show checkbox check/uncheck based on my condition.


Solution

  • I tried by modify my query before binding to the datagrid and added "case" to my query

    Select ID ,DESC, CASE WHEN [STATUS] = 0 THEN 'True' WHEN [STATUS] = 1 THEN 'False' END AS  [Active], ORDER [Order] from tbldesc
    

    its working fine for me.