views:

22

answers:

1

I have class with const fields like this

Areas
{
  public const int Area1Id = 1;
  public const int Area2Id = 2;
  public const int Area3Id = 3;
}

And a template which is binded to Area class. Area class has int TypeId property, and I want to show different things depending TypeId property

Code like this works perfectly

 <DataTrigger Binding="TypeId" Value="1" > 
   ...
 </DataTrigger>
 <DataTrigger Binding="TypeId" Value="2" > 
   ...
 </DataTrigger>
 <DataTrigger Binding="TypeId" Value="3" > 
   ...
 </DataTrigger>

Now my question is how to set my const values instead of DataTrigger value

<DataTrigger Binding="TypeId" Value="can i bind to Areas.Area1Value?" > 
       ...
</DataTrigger>
+2  A: 

Use x:Static to reference static fields, static properties, constants, or enumeration values:

<DataTrigger Binding="{Binding TypeId}" Value="{x:Static local:Areas.Area1Id}">
Quartermeister
It works, Thanks a lot for answer
ArsenMkrt