В ресурсы добавляем данные об enum:


<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="Gender">
  <ObjectDataProvider.MethodParameters>
    <x:Type TypeName="self:Gender"/>
  </ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</code>

Далее используем его в коде:


<Style TargetType="{x:Type TextBlock}">
<Setter Property="Text" Value="Н/д"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Gender}" Value="{x:Static Member=self:Gender.Male}">
<Setter Property="Text" Value="Муж"/>
</DataTrigger>
<DataTrigger Binding="{Binding Gender}" Value="{x:Static Member=self:Gender.Female}">
<Setter Property="Text" Value="Жен"/>
</DataTrigger>
</Style.Triggers>
</Style>

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>