Disabled color of NumBox header

你。 提交于 2021-01-29 05:22:05

问题


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>

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?


回答1:


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?

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

Disabled color of NumBox header

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


来源:https://stackoverflow.com/questions/65073268/disabled-color-of-numbox-header

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!