4

AutomationProperties.Name値を別の色でスタイルすることは可能ですか? アプリの暗いテーマから基本的なテキストの色を取得します。カスタムの背景色があるため、この属性に特定のForegroundColorとが必要です ( )TextColorValue="OtherUserAppBarButton"

<Style x:Key="LogoutAppBarButtonStyle" TargetType="ButtonBase" 
              BasedOn="{StaticResource AppBarButtonStyle}">
    <Setter Property="AutomationProperties.AutomationId" Value="OtherUserAppBarButton"/>
    <Setter Property="AutomationProperties.Name" Value="Other User"/>
    <Setter Property="Content" Value="&#xE1A6;"/>
    <Setter Property="Foreground" Value="#ffffffff" />
</Style>

誰かアイデアはありますか?

4

1 に答える 1

3

AppBarButtonStyleこれを実現するには、ボタン スタイルの基にするものを変更する必要があります。プロジェクト内で見つけることができますCommon\StandardStyles.xaml。このファイル内のスタイルを直接変更するかApp.xaml、未変更のスタイルも必要な場合は内部にコピーを作成できます。

スタイルの 内の次のブロックを変更する必要がありますControlTemplate

<TextBlock
    x:Name="TextLabel"
    Text="{TemplateBinding AutomationProperties.Name}"
    Foreground="{StaticResource AppBarItemForegroundThemeBrush}"
    Margin="0,0,2,0"
    FontSize="12"
    TextAlignment="Center"
    Width="88"
    MaxHeight="32"
    TextTrimming="WordEllipsis"
    Style="{StaticResource BasicTextStyle}"/>

ご覧のとおり、Foregroundプロパティは に固定されていAppBarItemForegroundThemeBrushます。{TemplateBinding Foreground}設定した色と一致するように変更するLogoutAppBarButtonStyleか、テンプレートで直接別のカスタム固定色を指定できます。

PointerOverまた、他の表示状態 ( 、PressedDisabledおよび)のスタイルについても忘れないでくださいChecked。テーマカラーにも設定されています。VisualStateManagerテンプレート内で変更できます

于 2012-12-01T06:07:03.573 に答える