I'm trying to work out how to change a cell's visibility based on it's value. I can do it using a trigger in a fieldlayout, but I want to do it as the record is initialised.
For example, I have 3 columns, and if the first column of a particular row contains a 0, I want to make that first cell, and the third cell blank, rather than displaying their values. Whatever I try to do in code, it seems to make the visibility change for every row rather than the rows that have 0 in the first column.
Am I missing something, or is this only possible using the trigger on the template in the fieldlayout definitions?
Cheers,
Rob
I've found another way around it - I've created 2 different field layouts, and I've then created 2 classes, one is for data that doesn't have a 0 in the first row, and the other for data that does. So the field layout with the key of the second class has the first and third fields as "Hidden", and the LabelLocation is also hidden.
The only problem that I'm coming across is that where it switches between layouts, it shows the column headers each time. Is there a property to get them to only show once, or can I instead code the headers into the actual grid rather than the layout?
Hello Rob,
I am not sure whether the InitializeRecord event is appropriate for this, as the Presenters are not yet generated.
However, you can use the following code snippet to achieve this:
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Value, RelativeSource={RelativeSource Self}}" Value="0">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
Hope this helps.