Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Special Characters in ConverterParameter-Value

There is this MSDN article about spcial characters in WPF/XAML:

But those Things seems not to work in XAML Attributes:

<MyControl Text={Binding SomeProperty, Converter={StaticResource SomeConverter}, ConverterParameter=Key&#61;Value;/>

I want to pass "Key=Value;" to the ConverterParameter.

For the moment I solved the problem this way:

<ItemsControl.ItemsSource>
    <Binding Path="LengthVersionList" Converter="{StaticResource LengthVersionListFilterConverter}">
        <Binding.ConverterParameter>
            <!-- Type=Singular; -->
            Type&#61;Singular;
        </Binding.ConverterParameter>
    </Binding>
</ItemsControl.ItemsSource>

But 7 Lines of Code for a simple assignment? Is there any way to do this in a single line?

Edit

Ok, got it to 3 Lines:

<ItemsControl.ItemsSource>
    <Binding Path="LengthVersionList" Converter="{StaticResource LengthVersionListFilterConverter}" ConverterParameter="Type&#61;Plural;" />
</ItemsControl.ItemsSource>

But if somebody would have a one-line solution I would be very pleased.

like image 766
Reini Avatar asked May 31 '11 12:05

Reini


1 Answers

You can use single quotes instead of double:

<ItemsControl ItemsSource="{Binding LengthVersionList, Converter={StaticResource LengthVersionListFilterConverter}, ConverterParameter='Type&#61;Plural;'}" />
like image 106
rooks Avatar answered Oct 08 '22 01:10

rooks