G
Guest
Hi,
I would like to use a multibinding to determine the fill value of my
rectangle style.
<Style x:Key="StyleRect" TargetType="{x:Type Rectangle}">
<Setter Property="Fill">
<Setter.Value>
<MultiBinding Converter="{StaticResource MyMultiValueConverter}">
<Binding Path="PropertyX"/>
<Binding Path="PropertyY"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
MyMultiValueConverter is a MultiValueConverter using 2 properties PropertyX
and PropertyY. It returns a string representing a color (e.g. "#F155F1").
When I am in Debug mode, I can see that MyMultiValueConverter gives the
right color back, but it doesn't change the color of my rectangle.
My rectangle is part of a ListBox Data Template.
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Rectangle Style="{StaticResource StyleRect}" />
....
</Grid>
</DataTemplate>
</ListBox.Template>
...
</ListBox>
If I use a normal binding, that works:
<Style x:Key="StyleRect" TargetType="{x:Type Rectangle}">
<Setter Property="Fill">
<Setter.Value>
<Binding Path="PropertyX" Converter="{StaticResource MyValueConverter}"/>
</Setter.Value>
</Setter>
</Style>
Thanks for your help
I would like to use a multibinding to determine the fill value of my
rectangle style.
<Style x:Key="StyleRect" TargetType="{x:Type Rectangle}">
<Setter Property="Fill">
<Setter.Value>
<MultiBinding Converter="{StaticResource MyMultiValueConverter}">
<Binding Path="PropertyX"/>
<Binding Path="PropertyY"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
MyMultiValueConverter is a MultiValueConverter using 2 properties PropertyX
and PropertyY. It returns a string representing a color (e.g. "#F155F1").
When I am in Debug mode, I can see that MyMultiValueConverter gives the
right color back, but it doesn't change the color of my rectangle.
My rectangle is part of a ListBox Data Template.
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Rectangle Style="{StaticResource StyleRect}" />
....
</Grid>
</DataTemplate>
</ListBox.Template>
...
</ListBox>
If I use a normal binding, that works:
<Style x:Key="StyleRect" TargetType="{x:Type Rectangle}">
<Setter Property="Fill">
<Setter.Value>
<Binding Path="PropertyX" Converter="{StaticResource MyValueConverter}"/>
</Setter.Value>
</Setter>
</Style>
Thanks for your help