Hi,
In a xamdatagrid, is it possible to disable a particual cell based on the value selected in another cell which is prior to that.
For e..g.,
Say we have a grid with Name and Age as columns, wherein Name Field is like popup listing giving employee names. After the selection of employee name, age automatically fills in and that particular cell got to be disabled.
Could you please tell me how this could be achieved?
Thanks,
Balaj Rajendran (WK - CCH, Torrance)
Hello Balaj,
You can do that, by creating a style for the CellValuePresenter. You should apply that style to only the Age field, as it will disable itself (the cell) based on a condition - HasContent:
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Style.Triggers>
<Trigger Property="HasContent" Value="True">
<Setter Property="IsEnabled" Value="False"/>
</Trigger>
</Style.Triggers>
</Style>
Let me know if that works in your scenario.
Hi, I've such situation: I have a field bound to boolean property of my data item. I need to disable editing of this field when data item has some specific states. If I set IsEnabled property of CellValuePresenter to False it's not possible to check/uncheck editor, but checkbox looks like it's enabled. I achieved correct behavior using style below. But, I'm curious if there is more simple way for that.
<Style x:Key="Checked" TargetType="idp:CellValuePresenter"> <Setter Property="IsEnabled" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type idp:DataRecordCellArea}}, Path=Record.DataItem, Converter={local:DataItemToCheckedFieldIsEnabledConverter}}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="idp:CellValuePresenter"> <CheckBox IsChecked="{TemplateBinding Value}" IsEnabled="{TemplateBinding IsEnabled}" HorizontalAlignment="Center" VerticalAlignment="Center"/> </ControlTemplate> </Setter.Value> </Setter> </Style>