2014-07-21 4 views
0

내 휴대 전화는 검은 색 테마이며 페이지 배경을 흰색으로 변환했습니다 (주제가 무엇이든간에). 그리고 이제 라디오 버튼이나 체크 박스를 사용할 때 모든 것이 흰색입니다. 전경색을 변경 한 후에도 변경되지 않습니다. 라디오 버튼의 채우기 색상을 변경하려면 어떻게해야합니까 ??라디오 버튼의 채우기 색상을 변경하는 방법은 무엇입니까?

답변

1

CHECK BOX CONTROL TEMPLATE에 대한 새 스타일을 만들어야합니다. 여기에 복사하여 주어진 코드를 복사하고 각각의 위치에서 COLOR를 변경하십시오. & 이것이 도움이되는지 확인하십시오. RADIO BUTTON의 경우와 같은 방법으로 제어 템플릿을 변경해야합니다.

<Style x:Key="PhoneRadioButtonCheckBoxBase" 
     BasedOn="{StaticResource PhoneButtonBase}" 
     TargetType="ToggleButton"> 
    <Setter Property="Background" 
      Value="**SET BACKGROUND COLOR YOU WANT FOR YOUR CB**" /> 
    <Setter Property="BorderBrush" 
      Value="**SET BORDER BRUSH COLOR YOU WANT FOR YOUR CB**" /> 
    <Setter Property="BorderThickness" 
      Value="3" /> 
    <Setter Property="HorizontalContentAlignment" 
      Value="Center" /> 
    <Setter Property="VerticalContentAlignment" 
      Value="Center" /> 
</Style> 

<Style x:Key="simpleCheckBoxStyle" 
     BasedOn="{StaticResource PhoneRadioButtonCheckBoxBase}" 
     TargetType="CheckBox"> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="CheckBox"> 
       <Grid Background="Transparent" 
         HorizontalAlignment="Left"> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal" /> 
          <VisualState x:Name="MouseOver" /> 
          <VisualState x:Name="Pressed"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" 
                    Storyboard.TargetName="CheckMark"> 
             <DiscreteObjectKeyFrame KeyTime="0" 
                   Value="{StaticResource PhoneButtonBasePressedForegroundBrush}" /> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="CheckStates"> 
          <VisualState x:Name="Checked"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" 
                    Storyboard.TargetName="CheckMark"> 
             <DiscreteObjectKeyFrame KeyTime="0"> 
              <DiscreteObjectKeyFrame.Value> 
               <Visibility>Visible</Visibility> 
              </DiscreteObjectKeyFrame.Value> 
             </DiscreteObjectKeyFrame> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Unchecked" /> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Grid> 
         <Grid Grid.Column="0" 
           VerticalAlignment="Top"> 
          <Border x:Name="CheckBackground" 
            BorderBrush="{TemplateBinding BorderBrush}" 
            BorderThickness="{StaticResource PhoneBorderThickness}" 
            Background="{TemplateBinding Background}" 
            HorizontalAlignment="Center" 
            Height="32" 
            IsHitTestVisible="False" 
            VerticalAlignment="Center" 
            Width="32" /> 
          <Path x:Name="CheckMark" 
            Data="M0,123 L39,93 L124,164 L256,18 L295,49 L124,240 z" 
            Fill="**SET COLOR FOR THE CHECK MARK**" 
            FlowDirection="LeftToRight" 
            HorizontalAlignment="Center" 
            Height="21" 
            IsHitTestVisible="False" 
            Stretch="Fill" 
            StrokeThickness="3" 
            StrokeLineJoin="Round" 
            Visibility="Collapsed" 
            VerticalAlignment="Center" 
            Width="23" /> 
         </Grid> 
        </Grid> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

다음 CB를 제공

<Style x:Key="PhoneButtonBase" 
    TargetType="ButtonBase"> 
<Setter Property="Background" 
     Value="{StaticResource TransparentBrush}" /> 
<Setter Property="BorderBrush" 
     Value="**SET BORDER BRUSH COLOR YOU WANT FOR YOUR CB**" /> 
<Setter Property="BorderThickness" 
     Value="3" /> 
<Setter Property="Template"> 
    <Setter.Value> 
     <ControlTemplate TargetType="ButtonBase"> 
      <Grid Background="Transparent"> 
       <Border x:Name="ButtonBackground" 
         BorderBrush="{TemplateBinding BorderBrush}" 
         BorderThickness="{TemplateBinding BorderThickness}" 
         Background="{TemplateBinding Background}" 
         CornerRadius="2"> 
        <ContentControl x:Name="ContentContainer" 
            ContentTemplate="{TemplateBinding ContentTemplate}" 
            Content="{TemplateBinding Content}" 
            Foreground="{TemplateBinding Foreground}" 
            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> 
       </Border> 
      </Grid> 
     </ControlTemplate> 
    </Setter.Value> 
</Setter> 

;

<CheckBox Style="{StaticResource simpleCheckBoxStyle}" /> 
0

은 당신의 목표를 달성하기 위해 RadioButtonStyle에 CheckBackground, 체크 마크와 ContentContainer에 대한 채움 색상을 변경합니다. 이처럼

<Ellipse x:Name="CheckBackground" Fill="{StaticResource RedColor}" HorizontalAlignment="Left" Height="32" IsHitTestVisible="False" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{StaticResource PhoneStrokeThickness}" VerticalAlignment="Center" Width="32"/> 
<Ellipse x:Name="CheckMark" Fill="{StaticResource WhiteColor}" HorizontalAlignment="Center" Height="16" IsHitTestVisible="False" Visibility="Collapsed" VerticalAlignment="Center" Width="16"/> 
<ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="1" Foreground="{StaticResource BlackColor}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="12,0,0,0" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> 

그리고 그 색상 스타일은

<SolidColorBrush Color="#FF0000" x:Key="RedColor"></SolidColorBrush> 
    <SolidColorBrush Color="#FFFFFF" x:Key="WhiteColor"></SolidColorBrush> 
    <SolidColorBrush Color="#000000" x:Key="BlackColor"></SolidColorBrush> 

지금 화이트와 같은 배경을 유지합니다. 너 끝났어. 참조 할 수 있도록 다음 스타일 (전체 코드)을 참조 할 수 있습니다.

<phone:PhoneApplicationPage.Resources> 

    <SolidColorBrush Color="#FF0000" x:Key="RedColor"></SolidColorBrush> 
    <SolidColorBrush Color="#FFFFFF" x:Key="WhiteColor"></SolidColorBrush> 
    <SolidColorBrush Color="#000000" x:Key="BlackColor"></SolidColorBrush> 

    <Style x:Key="PhoneButtonBase" TargetType="ButtonBase"> 
     <Setter Property="Background" Value="Transparent"/> 
     <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/> 
     <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/> 
     <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/> 
     <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/> 
     <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/> 
     <Setter Property="Padding" Value="10,5,10,6"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ButtonBase"> 
        <Grid Background="Transparent"> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"/> 
           <VisualState x:Name="Pressed"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneButtonBasePressedForegroundBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Disabled"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}"> 
          <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> 
         </Border> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
    <Style x:Key="PhoneRadioButtonCheckBoxBase" BasedOn="{StaticResource PhoneButtonBase}" TargetType="ToggleButton"> 
     <Setter Property="Background" Value="{StaticResource PhoneRadioCheckBoxBrush}"/> 
     <Setter Property="BorderBrush" Value="{StaticResource PhoneRadioCheckBoxBorderBrush}"/> 
     <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMedium}"/> 
     <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/> 
     <Setter Property="HorizontalContentAlignment" Value="Left"/> 
     <Setter Property="VerticalContentAlignment" Value="Center"/> 
     <Setter Property="Padding" Value="0"/> 
    </Style> 
    <Style x:Key="RadioButtonStyle1" BasedOn="{StaticResource PhoneRadioButtonCheckBoxBase}" TargetType="RadioButton"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="RadioButton"> 
        <Grid Background="Transparent"> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"/> 
           <VisualState x:Name="Pressed"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="CheckBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneRadioCheckBoxPressedBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="CheckMark"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneButtonBasePressedForegroundBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Disabled"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Stroke" Storyboard.TargetName="CheckBackground"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="CheckMark"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"> 
              <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
          </VisualStateGroup> 
          <VisualStateGroup x:Name="CheckStates"> 
           <VisualState x:Name="Checked"> 
            <Storyboard> 
             <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CheckMark"> 
              <DiscreteObjectKeyFrame KeyTime="0"> 
               <DiscreteObjectKeyFrame.Value> 
                <Visibility>Visible</Visibility> 
               </DiscreteObjectKeyFrame.Value> 
              </DiscreteObjectKeyFrame> 
             </ObjectAnimationUsingKeyFrames> 
            </Storyboard> 
           </VisualState> 
           <VisualState x:Name="Unchecked"/> 
           <VisualState x:Name="Indeterminate"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Grid Margin="{StaticResource PhoneTouchTargetLargeOverhang}"> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="32"/> 
           <ColumnDefinition Width="*"/> 
          </Grid.ColumnDefinitions> 
          <Ellipse x:Name="CheckBackground" Fill="{StaticResource RedColor}" HorizontalAlignment="Left" Height="32" IsHitTestVisible="False" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{StaticResource PhoneStrokeThickness}" VerticalAlignment="Center" Width="32"/> 
          <Ellipse x:Name="CheckMark" Fill="{StaticResource WhiteColor}" HorizontalAlignment="Center" Height="16" IsHitTestVisible="False" Visibility="Collapsed" VerticalAlignment="Center" Width="16"/> 
          <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="1" Foreground="{StaticResource BlackColor}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="12,0,0,0" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> 
         </Grid> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</phone:PhoneApplicationPage.Resources> 

내가 시도한 소스 코드를 참조 할 수 있습니다. 또한 CheckBox에 도움이 될 수있는 스타일이 있습니다. http://1drv.ms/1sS4loX

관련 문제