peterh
Topic Author
Posts: 21
Joined: 13 Mar 2015, 13:50

[C#] Resolving static enum reference

18 Nov 2015, 16:26

I am writing a DataTrigger that's supposed to react to changes in an enum:
<DataTrigger Binding="{Binding MyEnum}" Value="{x:Static ns:AnEnum.A}">
  <Setter Property="Content" Value="{StaticResource ResourceA}"/>
</DataTrigger>
<DataTrigger Binding="{Binding MyEnum}" Value="{x:Static ns:AnEnum.B}">
  <Setter Property="Content" Value="{StaticResource ResourceB}"/>
</DataTrigger>
But when compiling, I get this error:
Parsing Static (@50,24).
Type 'NameSpace.MyEnum' not registered
I have checked that all references are correct. Does Noesis not support referring to C# enums in this way?
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: [C#] Resolving static enum reference

20 Nov 2015, 18:19

Right now enums are treated as strings, so it should work like this:
<DataTrigger Binding="{Binding MyEnum}" Value="A">
  <Setter Property="Content" Value="{StaticResource ResourceA}"/>
</DataTrigger>
<DataTrigger Binding="{Binding MyEnum}" Value="B">
  <Setter Property="Content" Value="{StaticResource ResourceB}"/>
</DataTrigger>
In future releases we plan to expose enum correctly as a type, and using x:Static should also work.

Who is online

Users browsing this forum: No registered users and 3 guests