2012-11-30 2 views
4

AutomationProperties.Name 값의 스타일을 다른 색상으로 지정할 수 있습니까? 내 응용 프로그램의 어두운 테마에서 기본 텍스트 색상을 얻습니다. 나는이 속성에 대해 특정 ForegroundColorTextColor 필요한 이유를 나는 사용자 정의 배경색 및 그게 전부가 (Value="OtherUserAppBarButton")TopAppBar 버튼 Windows Store 앱의 자동화 속성 스타일

<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> 

아이디어 사람을 했습니까?

답변

3

버튼 스타일을 기반으로하는 AppBarButtonStyle을 수정해야합니다. 프로젝트 내에 Common\StandardStyles.xaml에서 찾을 수 있습니다. 이 파일의 스타일을 직접 수정하거나 수정되지 않은 스타일이 필요한 경우 App.xaml 안에 사본을 만들 수 있습니다.

당신은 내부의 다음 블록을 변경해야 스타일의 ControlTemplate : 당신이 Foreground 속성이 AppBarItemForegroundThemeBrush에 고정되어 볼 수 있듯이

<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}"/> 

. {TemplateBinding Foreground}으로 변경하여 LogoutAppBarButtonStyle에서 설정 한 색상과 일치 시키거나 템플릿에서 직접 다른 고정 된 고정 색상을 지정할 수 있습니다.

또한 다른 시각적 상태 (PointerOver, Pressed, DisabledChecked)의 스타일에 대해 잊지 마세요. 테마 색상으로도 설정됩니다. 템플릿의 경우 VisualStateManager 내부에서 변경할 수 있습니다.

관련 문제