我试图在我自己的类型ServiceControllerStatus (在System.ServiceProcess中找到的一个枚举)类中为一个名为“Status”的属性添加一个数据触发器。
我将其添加到XAML中:
xmlns:System="clr-namespace:System.ServiceProcess;assembly=System.ServiceProcess.dll"
并试图通过以下操作使用基于“状态”值的数据触发器:
<DataTrigger Binding="{Binding Path=Status}" >
<DataTrigger.Value>
<System:ServiceControllerStatus>Running</System:ServiceControllerStatus>
</DataTrigger.Value>
<Setter TargetName="border" Property="BorderBrush" Value="Green"/>
</DataTrigger>
但正在收到一个错误“XML命名空间'clr-namespace:System.ServiceProcess;assembly=System.ServiceProcess.dll”中不存在标记'ServiceControllerStatus‘。
是否可以使用在系统命名空间中定义的枚举,还是必须仅引用在您自己的类中定义的枚举?
谢谢!
发布于 2013-08-15 20:42:02
您可以在{x:Static}
表单中使用枚举。
<DataTrigger Binding="{Binding Path=Status}"
Value="{x:Static System:ServiceControllerStatus.Running}">
<Setter TargetName="border" Property="BorderBrush" Value="Green"/>
</DataTrigger>
更新:
在程序集语句中不要使用.dll扩展字符串。
assembly=System.ServiceProcess.dll
-> assembly=System.ServiceProcess
xmlns:System="clr-namespace:System.ServiceProcess;assembly=System.ServiceProcess"
PS:我不擅长英语。
https://stackoverflow.com/questions/18264958
复制相似问题