在 XAML 中设置多个枚举标志
问题描述:
有没有办法在 XAML 中设置多个枚举标志(传统上在代码隐藏中由 | 分隔)?我试过类似的东西:
Is there any way to set multiple enum flags (that are traditionally separated by | in codebehind) in XAML? I tried something like:
<ns:SomeControl Flags="FlagA|FlagB" />
但这没有用.
答
WPF 确实通过类型转换器支持这一点.可以通过在枚举值之间使用逗号来完成:
WPF does support this through a type converter. It can be done by using a comma in between enum values:
<ns:SomeControl Flags="FlagA,FlagB" />