Hello again,
Ok, so i have the following problem:
I have a xamdatagrid linked to a datatable that is dynamically created. I store the index of some columns and after that, depending on the value of each cell, I insert a picture.
I have the following code and trigger, pretty simple:
private void dg_InitializeRecord(object sender, InitializeRecordEventArgs e)
{
e.Record.FieldLayout.Fields[myDynamicIndex].Settings.CellValuePresenterStyle = dg.FindResource("st") as Style;
}
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=Cells[ ? MY PROBLEM ? ].Value, Mode=OneWay}" Value="1">
<Setter Property="Visibility" TargetName="green" Value="Hidden"/>
<Setter Property="Visibility" TargetName="red" Value="Visible"/>
</DataTrigger>
</ControlTemplate.Triggers>
As you can see, i cannot get the index of the cell in xaml, as it is dynamically set in my .cs code. I tried the following but it didn't work
Binding="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type igDP:Cell}}}"
Binding="{Binding Value,
RelativeSource={RelativeSource AncestorType={x:Type igDP:Cell}}}"
Can anyone help?
Hello,
The cells collection has both int(index) and string(name) indexators. Is it possible in your scenario that you know the name of the field? Like this:
DataTrigger Binding="{Binding Path=Cells[nameColumn].Value, Mode=OneWay}" Value="1">
Unfortunately no.. The columns in my dataTable are generated via some imputs that come from a windows form.. Is there no way of retrieving the object that is linked to the dataTrigger in my xaml code? Because then i would cast it to a cell.. as i said before, i tried this, but it didn't work : {Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xcdg:Cell}}