How to use multibiding with a Style Setter
Asked Answered
S

1

5

The alternate row style is defined as:

<Style TargetType="telerik:GridViewRow">
     <Setter Property="Background" Value="{Binding Color,Converter={StaticResource dataToColorConverter}}">
</Style>

But I want to update the rowstyle depedninng on multiple values. I want to achieve something like this.

<Style>
    <Setter Property="Background" >
               <MultiBinding Converter={StaticResource  dataToColorConverter}>
               <Binding Path="Color"/>
               <Binding ElementName="myListBox" Path="SelectedItem"/>
               </MultiBinding>
    </Setter>
</Style>

But getting the error "The type 'Setter' does not support direct content."

Swollen answered 19/4, 2013 at 10:45 Comment(0)
S
13

Because the Setter element doesn't support direct content, you must specify that you are setting the Value property (include "<Setter.Value>" in your XAML):

<Setter Property="Background" >
    <Setter.Value>
        <MultiBinding Converter="{StaticResource dataToColorConverter}" >
            <Binding Path="Color" />
            <Binding ElementName="myListBox" Path="SelectedItem" />
        </MultiBinding>
    </Setter.Value>
</Setter>
Sarre answered 19/4, 2013 at 10:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.