2016-10-24 29 views
0

私はラジオボタンのスタイリングをしてカラーピッカーを作成しました。ラジオボタンのコンテンツプロパティと他のスタイリングを削除しました。下記参照。 予想される動作:周囲にパディングスペースがない楕円のみです。 しかし、ラジオボタンの幅と高さを設定しても、楕円の周りに余分なスペースができています。私は間違っていますか?UWPでのラジオボタンのスタイル設定

enter image description here

私のXAML:

<RadioButton x:Name="Blue" Tag="0" Width="32" Height="32" 
       RelativePanel.AlignTopWithPanel="True" 
       RelativePanel.AlignLeftWithPanel="True" 
       GroupName="ColorPicker" 
       Background="#C6F5F9" Checked="Color_Checked" Style="{StaticResource ColorPickerStyle}"/> 

私のラジオボタンのスタイル:

<Style x:Key="ColorPickerStyle" TargetType="RadioButton"> 
    <Setter Property="Background" Value="{ThemeResource RadioButtonBackground}"/> 
    <Setter Property="Foreground" Value="{ThemeResource RadioButtonForeground}"/> 
    <Setter Property="BorderBrush" Value="{ThemeResource RadioButtonBorderBrush}"/> 
    <Setter Property="Margin" Value="4,4,4,4"/> 
    <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/> 
    <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/> 
    <Setter Property="UseSystemFocusVisuals" Value="True"/> 
    <Setter Property="FocusVisualMargin" Value="-7,-3,-7,-3"/> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="RadioButton"> 
       <Grid x:Name="RootGrid" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Background="Transparent"> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal"/> 
          <VisualState x:Name="Pressed"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CheckGlyph"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Disabled"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CheckGlyph"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="CheckStates"> 
          <VisualState x:Name="Checked"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CheckGlyph"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Unchecked"> 
           <Storyboard> 
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="CheckGlyph"> 
             <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> 
            </ObjectAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Indeterminate"/> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Ellipse x:Name="OuterEllipse" Stroke="Black" StrokeThickness="2" Width="{TemplateBinding Width}" Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" UseLayoutRounding="False"/> 
        <FontIcon x:Name="CheckGlyph" FontSize="16" Height="16" Width="16" Glyph="&#xE8FB;" 
             UseLayoutRounding="False" AutomationProperties.Name="Select"/> 
       </Grid> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
+2

Padding、MinWidth、MinHeightプロパティを0に設定してみてください –

+1

あなたの楕円に設定した 'StrokeThickness'を意味しますか?そのスペース? –

+0

。 @クリスは正しいです。スクリーンショットの黒いストロークを見ることができます。 –

答えて

1

0にのminWidthとminHeightのプロパティを設定するには、問題を修正しました。

関連する問題