By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,678 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,678 IT Pros & Developers. It's quick & easy.

XAML MultiBinding and MultiConverter in a style definition

P: n/a
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
Jun 22 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.