... and if you need the converter, that should go in the Binding for the
Background

On Thu, Nov 18, 2010 at 11:21 AM, Miguel Madero <[email protected]> wrote:

> Use TemplateBinding for the Background of the Border in the ControlTemplate
> and DataBinding ({Binding}) for the Background prioperty of the cell
>
> Style x:Key="BinaryCellStyle" TargetType="{x:Type DataGridCell}">
>
>   <Setter Property="Background" Value={Binding SomeProperty}>
>
>
>
>
> On Thu, Nov 18, 2010 at 9:11 AM, Greg Keogh <[email protected]> wrote:
>
>> 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 ????????????????????}">      <----I*s
>> this possible?*
>>
>>           <ContentPresenter HorizontalAlignment="Center"/>
>>
>>         </Border>
>>
>>       </ControlTemplate>
>>
>>     </Setter.Value>
>>
>>   </Setter>
>>
>> </Style>
>>
>> _______________________________________________
>> ozwpf mailing list
>> [email protected]
>> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>>
>>
>
>
> --
> Miguel A. Madero Reyes
> www.miguelmadero.com (blog)
> [email protected]
>



-- 
Miguel A. Madero Reyes
www.miguelmadero.com (blog)
[email protected]
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf

Reply via email to