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
180
how to change checkbox's IsEnable property based on datasource's field value
posted

I'm binding my xamDataGrid with entity class. All of my xamDataGrid's columns are UnboundFields. One of the field's contain checkbox and is binded to one of the datasource's field.

This field is defined like this:

<igDP:UnboundField Name="ReportSelector" Label=" " Column="0" BindingPath="IsSelected" BindingMode="TwoWay">

<igDP:UnboundField.Settings>

<igDP:FieldSettings CellValuePresenterStyle="{StaticResource CheckboxSelectField}" CellMinWidth="20" LabelWidth="20" CellMaxWidth="20" LabelMaxWidth="20"/>

</igDP:UnboundField.Settings>

</igDP:UnboundField>

 

And I override its CellValuePresenterStyle with style named CheckboxSelectField. This style is defined like this:

<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="CheckboxSelectField">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

<CheckBox Name="checkBoxRowSelector" Style="{StaticResource EnableMeetingMaterialsCheckBoxStyle}"

HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding IsSelected}"

Checked="checkBoxRowSelector_Checked" Unchecked="checkBoxRowSelector_Unchecked"/>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

 

The CheckboxSelectField has a style for the checkbox which is defined below. My checkbox is bindign to another field in my datasource different from the BindingPath set from the UnboundField.

<Style x:Key="EnableMeetingMaterialsCheckBoxStyle" TargetType="{x:Type CheckBox}">

<Style.Triggers>

<DataTrigger Binding="{Binding Path=FileStatus}" Value="2">

<Setter Property="IsEnabled" Value="False" />

</DataTrigger>

<DataTrigger Binding="{Binding Path=FileStatus}" Value="4">

<Setter Property="IsEnabled" Value="False" />

</DataTrigger>

<DataTrigger Binding="{Binding Path= FileStatus}" Value="0">

<Setter Property="IsEnabled" Value="True" />

</DataTrigger>

<DataTrigger Binding="{Binding Path= FileStatus}" Value="1">

<Setter Property="IsEnabled" Value="True" />

</DataTrigger>

<DataTrigger Binding="{Binding Path= FileStatus}" Value="3">

<Setter Property="IsEnabled" Value="True" />

</DataTrigger>

</Style.Triggers>

</Style>

 

This is not working :( :( :( I really need your immediate help for this. Thank you very much.

  • 180
    Verified Answer
    posted

    I have found a solution.

    instead of :

    <DataTrigger Binding="{Binding Path=FileStatus}" Value="2">

    <Setter Property="IsEnabled" Value="False" />

    </DataTrigger>

     

    it should be:

    <DataTrigger Binding="{Binding Path=DataItem.FileStatus}" Value="2">

    <Setter Property="IsEnabled" Value="False" />

    </DataTrigger>