在 ConverterParameter-Value 中使用特殊字符
有一篇关于 WPF/XAML 中特殊字符的 MSDN 文章:
但是那些XAML 属性中的情况似乎不起作用:
<MyControl Text={Binding SomeProperty, Converter={StaticResource SomeConverter}, ConverterParameter=Key=Value;/>
我想将 "Key=Value;"
传递给 ConverterParameter
。
目前我是这样解决问题的:
<ItemsControl.ItemsSource>
<Binding Path="LengthVersionList" Converter="{StaticResource LengthVersionListFilterConverter}">
<Binding.ConverterParameter>
<!-- Type=Singular; -->
Type=Singular;
</Binding.ConverterParameter>
</Binding>
</ItemsControl.ItemsSource>
但是 7 行代码就可以完成一个简单的任务?有什么方法可以在一行中完成此操作吗?
编辑
好的,将其改为 3 行:
<ItemsControl.ItemsSource>
<Binding Path="LengthVersionList" Converter="{StaticResource LengthVersionListFilterConverter}" ConverterParameter="Type=Plural;" />
</ItemsControl.ItemsSource>
但如果有人能提供一行解决方案,我会非常高兴。
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; -->
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用单引号而不是双引号:
You can use single quotes instead of double: