Home > DeveloperSection > Forums > Accessing system enums in WPF datatemplates
Alex Leblois
Alex Leblois

Total Post:67

Posted on    August-16-2013 5:48 AM


 1 Reply(s)
 3999  View(s)
Rate this:
Hi Developer!

I'm trying to add a data trigger for a property called 'Status' in my own class of type ServiceControllerStatus (an enum found in System.ServiceProcess).

I added this to the XAML:


And am trying to use data triggers based on the value of 'Status' by doing this:

<DataTrigger Binding="{Binding Path=Status}" >




    <Setter TargetName="border" Property="BorderBrush" Value="Green"/>


But am receiving an error "The tag 'ServiceControllerStatus' does not exist in XML namespace 'clr-namespace:System.ServiceProcess;assembly=System.ServiceProcess.dll"

Is it possible to use enums defined in system namespaces, or must you only reference enums defined in your own classes?

Thank you!

shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    August-17-2013 7:08 AM


You can use enum with the {x:Static} form.

<DataTrigger Binding="{Binding Path=Status}"

             Value="{x:Static System:ServiceControllerStatus.Running}">

    <Setter TargetName="border" Property="BorderBrush" Value="Green"/>



Don't want to miss updates? Please click the below button!

Follow MindStick