开发者

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; --&开发者_开发技巧gt;
            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.


You can use single quotes instead of double:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜