2017-07-05 11 views
0

プロジェクトでページが混雑していて、1つのページに多くのチェックボックスコントロールを配置したいので、のチェックボックスのサイズを変更する方法を探しています。 私のチェックボックスの高さと幅を変更すると、そのテキストの一部が消えます。つまり、私は自分のチェックボックスを拡大し、小さなチェックボックスを作る必要があります。Windowsユニバーサルアプリケーションでチェックボックスのサイズを変更する

Example

+1

CheckBoxの[デフォルトスタイル](https://msdn.microsoft.com/en-us/library/windows/apps/mt299114.aspx?f=255&MSPPError=-2147217396)をチェックしましたか?彼らは '120'の最小幅を持っています。 –

+0

私は知っていますが、私は小さなチェックボックスが必要です...解決策は何ですか? –

+3

それは電話用ですか?あなたのユーザーはまた、小さな指を必要とするため。 –

答えて

3

もちろんScaleTransformを使用しますが、そのスタイルはあなたに多くの柔軟性を提供します修正することにより、それをスケールダウンすることができます。

<Style x:Key="TinyCheckBoxStyle" 
       TargetType="CheckBox"> 
      <Setter Property="Padding" 
        Value="4,0,0,0" /> 
      <Setter Property="HorizontalContentAlignment" 
        Value="Left" /> 
      <Setter Property="FontSize" 
        Value="11" /> 
      <Setter Property="MinWidth" 
        Value="0" /> 
      <Setter Property="MinHeight" 
        Value="0" /> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="CheckBox"> 
         <Grid x:Name="RootGrid" 
           BorderBrush="{TemplateBinding BorderBrush}" 
           BorderThickness="{TemplateBinding BorderThickness}" 
           Background="{TemplateBinding Background}"> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="Auto" /> 
           <ColumnDefinition Width="*" /> 
          </Grid.ColumnDefinitions> 

          <VisualStateManager.VisualStateGroups> 
           <!-- Add default visual states back in here --> 
          </VisualStateManager.VisualStateGroups> 

          <Grid> 
           <Rectangle x:Name="NormalRectangle" 
              Fill="{ThemeResource CheckBoxCheckBackgroundFillUnchecked}" 
              Height="12" 
              Stroke="{ThemeResource CheckBoxCheckBackgroundStrokeUnchecked}" 
              StrokeThickness="{ThemeResource CheckBoxBorderThemeThickness}" 
              UseLayoutRounding="False" 
              Width="12" /> 
           <FontIcon x:Name="CheckGlyph" 
              Foreground="{ThemeResource CheckBoxCheckGlyphForegroundUnchecked}" 
              FontSize="{TemplateBinding FontSize}" 
              FontFamily="{ThemeResource SymbolThemeFontFamily}" 
              Glyph="&#xE001;" 
              Opacity="0" /> 
          </Grid> 
          <ContentPresenter x:Name="ContentPresenter" 
               AutomationProperties.AccessibilityView="Raw" 
               ContentTemplate="{TemplateBinding ContentTemplate}" 
               ContentTransitions="{TemplateBinding ContentTransitions}" 
               Content="{TemplateBinding Content}" 
               Grid.Column="1" 
               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
               Margin="{TemplateBinding Padding}" 
               TextWrapping="Wrap" 
               VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> 
         </Grid> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

は基本的に、あなたがNormalRectangleCheckGlyphFontSizeのサイズを小さくする必要がある -

は、ここでの例です。注釈を簡略化するためにビジュアル状態を削除しましたが、default styleから戻す必要があります。

+1

それは私が欲しいものだった、私は適切に質問をしなかったことは申し訳なく思っています。 –

+0

心配はいりません。そのため、質問用の編集ボタンがあります。 :) –

関連する問題