2014-05-12 2 views
1

MahApps Metro probvides에서 SquareButtonStyle에 1 픽셀 경계가 없음을 알았습니다. 나는이 스타일의 라인을 따라 뭔가 얻을 찾고 :MahApps Metro에서 SqaureButton 스타일 덮어 쓰기

enter image description here

을 (비주얼 스튜디오의 버튼 스타일) 그리고 메트로 스타일은 다음과 같이이다 : 나는 보았다

enter image description here

단추 스타일에 대한 XAML을 통해 표시되지만 단추의 테두리 두께가 1임을 나타냅니다. 위의 단추와 같이 다른 단추의 테두리가 1 인 경우 어떻게 될 수 있습니까? 어떻게하면이 버튼을 덮어 쓰게 될까요?

<Style x:Key="SquareButtonStyle" 
     TargetType="{x:Type Button}"> 
    <Setter Property="MinHeight" 
      Value="25" /> 
    <Setter Property="FontFamily" 
      Value="{DynamicResource DefaultFont}" /> 
    <Setter Property="FontWeight" 
      Value="SemiBold" /> 
    <Setter Property="Background" 
      Value="{DynamicResource WhiteBrush}" /> 
    <Setter Property="BorderBrush" 
      Value="{DynamicResource BlackBrush}" /> 
    <Setter Property="Foreground" 
      Value="{DynamicResource TextBrush}" /> 
    <Setter Property="Padding" 
      Value="5,6" /> 
    <Setter Property="BorderThickness" 
      Value="1" /> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type Button}"> 
       <Grid> 
        <VisualStateManager.VisualStateGroups> 
         <VisualStateGroup x:Name="CommonStates"> 
          <VisualState x:Name="Normal" /> 
          <VisualState x:Name="MouseOver"> 
           <Storyboard> 
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" 
                    Storyboard.TargetName="MouseOverBorder"> 
             <EasingDoubleKeyFrame KeyTime="0" 
                   Value="1" /> 
            </DoubleAnimationUsingKeyFrames> 
            <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)" 
                     Storyboard.TargetName="MouseOverBorder"> 
             <EasingThicknessKeyFrame KeyTime="0" 
                   Value="2" /> 
            </ThicknessAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Pressed"> 
           <Storyboard> 
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" 
                    Storyboard.TargetName="PressedBorder"> 
             <EasingDoubleKeyFrame KeyTime="0" 
                   Value="1" /> 
            </DoubleAnimationUsingKeyFrames> 
            <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)" 
                     Storyboard.TargetName="MouseOverBorder"> 
             <EasingThicknessKeyFrame KeyTime="0" 
                   Value="0" /> 
            </ThicknessAnimationUsingKeyFrames> 
            <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)" 
                     Storyboard.TargetName="PressedBorder"> 
             <EasingThicknessKeyFrame KeyTime="0" 
                   Value="2" /> 
            </ThicknessAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
          <VisualState x:Name="Disabled"> 
           <Storyboard> 
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" 
                    Storyboard.TargetName="DisabledVisualElement"> 
             <SplineDoubleKeyFrame KeyTime="0" 
                   Value="0.7" /> 
            </DoubleAnimationUsingKeyFrames> 
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" 
                    Storyboard.TargetName="contentPresenter"> 
             <EasingDoubleKeyFrame KeyTime="0" 
                   Value="0.3" /> 
            </DoubleAnimationUsingKeyFrames> 
           </Storyboard> 
          </VisualState> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="FocusStates"> 
          <VisualState x:Name="Focused" /> 
          <VisualState x:Name="Unfocused" /> 
         </VisualStateGroup> 
         <VisualStateGroup x:Name="ValidationStates"> 
          <VisualState x:Name="Valid" /> 
          <VisualState x:Name="InvalidFocused" /> 
          <VisualState x:Name="InvalidUnfocused" /> 
         </VisualStateGroup> 
        </VisualStateManager.VisualStateGroups> 
        <Border x:Name="Background" 
          BorderBrush="{DynamicResource BlackBrush}" 
          BorderThickness="2" 
          Background="{TemplateBinding Background}" /> 
        <Rectangle x:Name="DisabledVisualElement" 
           Fill="{DynamicResource ControlsDisabledBrush}" 
           IsHitTestVisible="false" 
           Opacity="0" /> 
        <Border x:Name="MouseOverBorder" 
          Background="{DynamicResource GrayBrush8}" 
          Opacity="0" /> 
        <Border x:Name="PressedBorder" 
          Background="{DynamicResource BlackBrush}" 
          Opacity="0" 
          BorderBrush="{DynamicResource BlackBrush}" /> 
        <ContentPresenter x:Name="contentPresenter" 
             ContentTemplate="{TemplateBinding ContentTemplate}" 
             Content="{TemplateBinding Content, Converter={StaticResource ToLowerConverter}}" 
             HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
             Margin="{TemplateBinding Padding}" 
             RecognizesAccessKey="True" 
             VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
             OpacityMask="{x:Null}" /> 
       </Grid> 

       <ControlTemplate.Triggers> 
        <Trigger Property="IsMouseOver" 
          Value="True"> 
         <Setter Property="Foreground" 
           Value="{DynamicResource BlackBrush}" /> 
        </Trigger> 
        <Trigger Property="IsPressed" 
          Value="true"> 
         <Setter Property="Foreground" 
           Value="{DynamicResource WhiteBrush}" /> 
        </Trigger> 
       </ControlTemplate.Triggers> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

답변

3

내가 생각의이 작품 <Border x:Name="Background" BorderBrush="{DynamicResource BlackBrush}" BorderThickness="2" Background="{TemplateBinding Background}" />

+0

좋아, 내가 시도하고 변경됩니다 모자 :

https://github.com/joazlazer/ModdingStudio/blob/master/ModdingStudio/ModdingStudio/Themes/Buttons.xaml

그것은 나에게이 있습니다. 왜 그 말은 borderThickness = "1"이 맨 위에 올까요? –

+0

을 사용하려는 경우 <테두리 x : 이름 = "배경"을 설정해야합니다. BorderBrush = "{DynamicResource BlackBrush}" BorderThickness = "{ DynamicResource BorderThickness} " Background ="{TemplateBinding Background} "/> 그렇지 않으면이 테두리에는 항상 기본값이 있습니다. –

1

하지 마십시오 : https://github.com/MahApps/MahApps.Metro/blob/master/MahApps.Metro/Styles/Controls.Buttons.xaml 여기

가있는 SquareButton XAML입니다 : 여기

는 button.xaml (편집 링크)에 대한 링크입니다 버튼의 텍스트 콘텐츠 발표자를 다음으로 설정하십시오 :

<ContentPresenter x:Name="contentPresenter" 
    ContentTemplate="{TemplateBinding ContentTemplate}" 
    Content="{TemplateBinding Content}" 
    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
    Margin="{TemplateBinding Padding}" 
    RecognizesAccessKey="True" 
    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
    OpacityMask="{x:Null}" /> 

텍스트를 소문자로 표시하지 않으려면 여기에 내가 내 한 방법입니다 http://i.imgur.com/5ZWa2ln.png

관련 문제