NumBox 的禁用颜色 header
Disabled color of NumBox header
由于 NumBox
似乎有一个错误,当控件被禁用时标签不会变暗(当然,其他控件也会),我尝试设置它的样式以强制执行此行为:
<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?
问题是 TextBlock
不包含 Disabled
状态。所以它不会起作用。
Disabled color of NumBox header
这是 NumberBox
的已知问题,已在最新版本中修复,请尝试使用以下命令安装 2.5.0-prerelease。
Install-Package Microsoft.UI.Xaml -Version 2.5.0-prerelease.201027002
由于 NumBox
似乎有一个错误,当控件被禁用时标签不会变暗(当然,其他控件也会),我尝试设置它的样式以强制执行此行为:
<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?
问题是 TextBlock
不包含 Disabled
状态。所以它不会起作用。
Disabled color of NumBox header
这是 NumberBox
的已知问题,已在最新版本中修复,请尝试使用以下命令安装 2.5.0-prerelease。
Install-Package Microsoft.UI.Xaml -Version 2.5.0-prerelease.201027002