8,757
社区成员
发帖
与我相关
我的任务
分享
<Label x:Name="xrayStatus" Height="80" Width="80" VerticalAlignment="Center" Grid.Column="1">
<Label.Style>
<Style TargetType="{x:Type Label}">
<Style.Triggers>
<DataTrigger Binding="{x:Static local:StatusInfoHelper.IsExposing}" Value="True">
<Setter Property="Background" Value="Blue"/>
</DataTrigger>
<DataTrigger Binding="{x:Static local:StatusInfoHelper.IsExposing}" Value="False">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Label x:Name="xrayStatus"
Height="80"
Width="80"
VerticalAlignment="Center" Grid.Column="1"
local:StatusInfoHelper.IsExposing="True" // 在这里设置附加属性即可
>
<Label.Style>
<Style TargetType="{x:Type Label}">
<Style.Triggers>
<Trigger Property="local:StatusInfoHelper.IsExposing" Value="True">
</Trigger>
<!-- Or -->
<DataTrigger Binding="{Binding Path=(local:StatusInfoHelper.IsExposing), Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="Background" Value="Blue"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>