2017-07-05 22 views
0

我在項目中擁擠了頁面,我想在單個頁面中放置太多的複選框控件,所以我正在尋找一種方法來調整我的複選框。 當我改變我的複選框的高度和寬度,其文本的一部分消失,換句話說,我需要縮放我的複選框,並使一些小複選框。調整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

不用擔心。這就是爲什麼有一個編輯按鈕的問題。 :) –

相關問題