加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

wpf – Style.DataTrigger在边框背景

发布时间:2020-12-16 08:04:55 所属栏目:百科 来源:网络整理
导读:我有下面的边界为什么我的TextBlock的前景可以正常工作,但是边框的背景总是保持不变(就好像IsDeleted属性总是假) Border DockPanel.Dock="Top" BorderBrush="Black" Background="#CBE2FF" BorderThickness="2" CornerRadius="5" Padding="0" Margin="5" Bor
我有下面的边界为什么我的TextBlock的前景可以正常工作,但是边框的背景总是保持不变(就好像IsDeleted属性总是假)
<Border DockPanel.Dock="Top" BorderBrush="Black" Background="#CBE2FF" BorderThickness="2" CornerRadius="5" Padding="0" Margin="5">
    <Border.Style>
        <Style TargetType="{x:Type Border}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsDeleted}" Value="True">
                    <Setter Property="Background" Value="#A00000"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Border.Style>
    <TextBlock Margin="5" FontWeight="Bold" FontSize="14" Text="Queue Details">
        <TextBlock.Style>
            <Style TargetType="{x:Type TextBlock}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsDeleted}" Value="True">
                        <Setter Property="Foreground" Value="White"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </TextBlock.Style>
    </TextBlock>
</Border>
您已经明确地设置了边框上的背景值。这比触发器更优先。删除Background =“#CBE2FF”并将其转换为样式。
<Border.Style>
   <Style TargetType="{x:Type Border}">
      <Setter Property="Background" Value="#CBE2FF"/>
      ...

这将有所帮助。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读