2014-08-27 8 views
-1

저는 며칠 동안 WPF로 작업 해 왔으며 Photoshop에서 프로젝트를 미리 디자인했습니다. 자, WPF 개발로가는 중입니다. 그러나 문제는 다음과 같습니다. Windows의 테마를 차단하는 방법이 있습니까? 내가 의미하는 바는 예. 버튼을 만들면 원하는대로 스타일이 지정되지만 마우스 오버/클릭 이벤트는 디자인을 덮어 씁니다. 궁극적으로는 완전히 사악 해 보입니다. 정말 나쁜 방식으로. 내 생각에, 내가 무엇을 찾고 있을지도 모르는 것은 CSS에서 액세스 할 수있는 와일드 카드와 동일합니다 ...Windows 테마의 스타일을 제거하는 방법?

답변

1

내가 당신에게 문제를 이해 Template 버튼의 속성을 사용할 수 있습니다.

Windows 리소스 섹션에 몇 가지 스타일 코드를 쓸 수 있습니다.

<Window x:Class="DataBinding.ButtonTemplating" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="ButtonTemplating" Height="300" Width="300"> 
<Window.Resources> 
    <Style TargetType="{x:Type Button}"> 
     <Setter Property="Background" Value="#373737" /> 
     <Setter Property="Foreground" Value="White" /> 
     <Setter Property="FontSize" Value="15" /> 
     <Setter Property="SnapsToDevicePixels" Value="True" /> 

     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type Button}"> 
        <Border CornerRadius="4" Background="{TemplateBinding Background}"> 

          <ContentPresenter x:Name="MyContentPresenter" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0" /> 

        </Border> 

        <ControlTemplate.Triggers> 
         <Trigger Property="IsMouseOver" Value="True"> 
          <Setter Property="Background" Value="#E59400" /> 
          <Setter Property="Foreground" Value="White" /> 

         </Trigger> 

         <Trigger Property="IsPressed" Value="True"> 
          <Setter Property="Background" Value="OrangeRed" /> 
          <Setter Property="Foreground" Value="White" /> 
         </Trigger> 
        </ControlTemplate.Triggers> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</Window.Resources> 
<Button Width="200" Height="50" VerticalAlignment="Top">WPF</Button> 

+0

tyvm! 매력처럼 작동합니다. –

0

네, 고유 한 컨트롤 템플릿을 적용하여 모든 Windows 테마를 재정의 할 수 있습니다. 마우스 오버/클릭 이벤트는이 템플릿의 일부입니다.

컨트롤 템플릿을 리소스의 일부로 만들면 모든 컨트롤에서 컨트롤 템플릿을 다시 사용할 수 있습니다.

기본 템플릿

는 여기에서 찾을 수 있습니다 : http://msdn.microsoft.com/en-us/library/aa970773(v=vs.110).aspx

버튼 스타일과 템플릿은 여기에서 찾을 수 있습니다 : 당신이 완전한 사용자 정의 버튼을 당신에게 다음에 따라 확인하려면, 그래서 http://msdn.microsoft.com/en-us/library/ms753328(v=vs.110).aspx

관련 문제