I have a DataTemplate
and a SolidColorBrush
in the DataTemplate.Resources
section.
I want to bind the color to a property of the same data object that the DataTemplate
itself is bound to.
However, this does not work. The brush is ignored. Why?
Here is the simplified code:
<DataTemplate DataType="{x:Type data:MyData}" x:Name="dtData">
<DataTemplate.Resources>
<SolidColorBrush x:Key="bg" Color="{Binding Path=Color, Converter={StaticResource colorConverter}" />
</DataTemplate.Resources>
<Border CornerRadius="15"
Background="{StaticResource bg}"
Margin="0"
Opacity="0.5"
Focusable="True">
</DataTemplate>
I understand I could set this directly also but I need the color to be a resource.