Bootstrap

textblock datatrigger 根据自身text内容改变颜色

                        <Grid.Resources>
                            <Style TargetType="TextBlock">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Text}" Value="正常">
                                        <Setter Property="Foreground" Value="Green"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Text}" Value="故障">
                                        <Setter Property="Foreground" Value="Red"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Text}" Value="告警">
                                        <Setter Property="Foreground" Value="Red"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Grid.Resources>

 

转载于:https://www.cnblogs.com/gbnw/p/11606800.html

;