NumBox 标题的禁用颜色 [英] Disabled color of NumBox header

查看:26
本文介绍了NumBox 标题的禁用颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 NumBox 似乎有一个错误,即在禁用控件时不使标签变暗(当然其他控件会这样做),我尝试对其进行样式设置以强制执行此行为:

As NumBox seems to have a bug of not dimming the label when the control is disabled (other controls do, of course), I try to style it to force this behavior:

  <Style TargetType="ux:NumberBox">
    <Setter Property="HeaderTemplate">
      <Setter.Value>
        <DataTemplate>
          <TextBlock x:Name="HeaderText" Text="{Binding}" Foreground="{ThemeResource TextControlHeaderForeground}">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="Disabled">
                  <VisualState.Setters>
                    <Setter Target="HeaderText.Foreground" Value="{ThemeResource SystemControlDisabledBaseMediumLowBrush}" />
                  </VisualState.Setters>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
          </TextBlock>
        </DataTemplate>
      </Setter.Value>
    </Setter>
  </Style>

虽然原来的 Foreground 没问题,但它没有发现视觉状态的变化,标签保持相同的颜色.我做错了什么?

While the original Foreground is OK, it doesn't pick up the change in the visual state and the label stays the same color. What am I doing wrong?

推荐答案

虽然原始的 Foreground 没问题,但它不会拾取视觉状态的变化,并且标签保持相同的颜色.我做错了什么?

While the original Foreground is OK, it doesn't pick up the change in the visual state and the label stays the same color. What am I doing wrong?

问题是 TextBlock 不包含 Disabled 状态.所以它不会工作.

The problem is TextBlock does not contains Disabled state. So it will not work.

NumBox 标题的禁用颜色

Disabled color of NumBox header

NumberBox,最新版本已修复,请尝试使用以下命令安装2.5.0-prerelease.

It's know issue for NumberBox, and it is fixed in latest version, please try to install 2.5.0-prerelease with following command.

Install-Package Microsoft.UI.Xaml -Version 2.5.0-prerelease.201027002

这篇关于NumBox 标题的禁用颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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