Topic Author
Posts: 34
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 Binding="{Binding MyEnum}" Value="{x:Static ns:AnEnum.B}">
  <Setter Property="Content" Value="{StaticResource ResourceB}"/>
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
Site Admin
Posts: 2327
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 Binding="{Binding MyEnum}" Value="B">
  <Setter Property="Content" Value="{StaticResource ResourceB}"/>
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: Google [Bot] and 4 guests