Dan
Dan

Reputation: 324

WPF - How to bind Style's Setter to element's Property?

In, WPF, XAML, I have a Style that's being applied to the items of a ComboBox, I want to get the current item's Content Property but this doesn't seem to work:

<dxe:ComboBoxEdit.Items>
    <Style TargetType="{x:Type dxe:ComboBoxEditItem}">
        <Style.Setters>
            <Setter Property="Content" Value="{Binding Converter={StaticResource CrsNameCvtor}, ConverterParameter={Binding Content,RelativeSource={RelativeSource Self}}}"/>
        </Style.Setters>
    </Style>
</dxe:ComboBoxEdit.Items>

Upvotes: 0

Views: 471

Answers (1)

Clemens
Clemens

Reputation: 128061

The Style should be assigned to the ComboBox's ItemContainerStyle property, and you don't need to set the Binding's ConverterParameter at all:

<dxe:ComboBoxEdit.ItemContainerStyle>
    <Style TargetType="dxe:ComboBoxEditItem">
        <Setter Property="Content"
                Value="{Binding Converter={StaticResource CrsNameCvtor}}"/>
    </Style>
</dxe:ComboBoxEdit.ItemContainerStyle>

Upvotes: 2

Related Questions