试图绑定到DataTrigger里面的枚举,为什么它不工作? [英] Trying to bind to enum inside of DataTrigger, why isn't it working?

查看:111
本文介绍了试图绑定到DataTrigger里面的枚举,为什么它不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的椭圆现在是红色的。

I would expect my Ellipse to be Red right now.

<UserControl x:Class="BenchmarkPlus.PMT.UI.Views.NotificationIndicator"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Models="clr-namespace:BenchmarkPlus.PMT.UI.Models"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             x:Name="root"
             DataContext="{x:Static Models:NotificationType.Error}">
  <Grid>
    <Ellipse>
      <Ellipse.Style>
        <Style TargetType="Ellipse">
          <Setter Property="Fill"
                  Value="Blue" />
          <Style.Triggers>
            <DataTrigger Binding="{Binding}"
                         Value="{x:Static Models:NotificationType.Info}">
              <Setter Property="Fill"
                      Value="Green" />
            </DataTrigger>
            <DataTrigger Binding="{Binding}"
                         Value="{x:Static Models:NotificationType.Error}">
              <Setter Property="Fill"
                      Value="Red" />
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </Ellipse.Style>
    </Ellipse>
  </Grid>
</UserControl>


推荐答案

这在VS2010设计器中似乎不起作用,但在VS11中。另一个原因要切换到VS11 beta:)

This doesn't appear to work in VS2010 designer, but does in VS11. Yet another reason to switch to VS11 beta :)

这篇关于试图绑定到DataTrigger里面的枚举,为什么它不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆