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=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=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=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=Plural;'}" />
精彩评论