2013-06-27 12 views
1

Expression Blend 4에서는 단추를 사용자 지정하려고합니다.WPF : Expression Blend에서 단추를 사용자 지정하여 한 상태의 모양을 변경하면 다른 모양이 동일하게됩니다.

창에서 버튼을 선택하고 마우스 오른쪽 버튼으로 클릭하고 "템플릿 편집"-> "복사본 편집"에서 자원 사전 인 "Button.xaml"에서 위치를 선택하십시오. 다음으로 Chrome을 삭제하고 Border을 추가하고 Border 아래에 ContentPresenter을 추가하십시오. 그런 다음 Border을 선택한 다음 "상태 패널"에서 MouseOver을 선택하고 Background과 'BorderBrush'를 모두 변경하십시오. 그러나 다른 사람의 모습도 MouseOver 주와 동일하게 변경됩니다.

"속성 패널"에서 "시스템 브러쉬 리소스"로 Brush을 지정합니다.

마찬가지로 이미지 : Background이 (가) MouseOver 상태로 변경되었습니다.

enter image description here

하지만 다른 국가의 Background들도 변경되었다 : enter image description here

Button.xaml

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"> 
    <Style x:Key="ButtonFocusVisual"> 
     <Setter Property="Control.Template"> 
      <Setter.Value> 
       <ControlTemplate> 
        <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
    <!-- Resource dictionary entries should be defined here. --> 
    <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0"> 
     <GradientStop Color="#F3F3F3" Offset="0"/> 
     <GradientStop Color="#EBEBEB" Offset="0.5"/> 
     <GradientStop Color="#DDDDDD" Offset="0.5"/> 
     <GradientStop Color="#CDCDCD" Offset="1"/> 
    </LinearGradientBrush> 
    <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/> 
    <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}"> 
     <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/> 
     <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/> 
     <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/> 
     <Setter Property="BorderThickness" Value="1"/> 
     <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> 
     <Setter Property="HorizontalContentAlignment" Value="Center"/> 
     <Setter Property="VerticalContentAlignment" Value="Center"/> 
     <Setter Property="Padding" Value="1"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type Button}"> 
        <Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}"> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal"/> 
           <VisualState x:Name="MouseOver"/> 
           <VisualState x:Name="Pressed"/> 
           <VisualState x:Name="Disabled"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <ContentPresenter/> 
        </Border> 
        <ControlTemplate.Triggers> 
         <Trigger Property="IsKeyboardFocused" Value="true"/> 
         <Trigger Property="ToggleButton.IsChecked" Value="true"/> 
         <Trigger Property="IsEnabled" Value="false"> 
          <Setter Property="Foreground" Value="#ADADAD"/> 
         </Trigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</ResourceDictionary> 

답변

0

나는 그것을 해결할 수 있습니다. 먼저 "상태 패널"에서 하나의 상태를 선택한 다음 "객체 및 타임 라인 패널"로 전환하고 "테두리"를 추가 한 다음 모양을 변경합니다.

이와 같이 :