After more hours of experimenting with binding and searching up and down
visual trees I am unable to find a way of converting a value into a
background colour in my grid. In a normal grid with pre-defined columns you
just go Background={Binding TheValue, Converter=MyConverter} and you turn
the value into a Brush.
However, my grid columns are all dynamically created and some of the columns
are manually assigned templates to avoid the "border collapse" alignment
problem I found. In my template below I can hard code the Background to
Yellow for example and it works, so I know this is the point where I want to
convert the colour. I can also hard code {Binding MyValue...} and it works
for MyValue.
But this template is applied to multiple columns and I'm unable to find the
column's value at the point of binding. I tried {Binding Content...} and
walking the tree to find the underlying value, but I can't find it. So is
there a way of {Binding} so I can get the column's value into the converter?
Am I simply missing some Binding syntax trick?
If not, my next step is to dynamically build the whole Style and Template
and inject the column name into the Background Binding. I haven't researched
that yet.
Greg
<Style x:Key="BinaryCellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
Background="{Binding ????????????????????}"> <----Is this
possible?
<ContentPresenter HorizontalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf