2014-09-16 2 views
0

템플릿을 사용하는 단추가 있습니다. 내 템플릿에는 올바르게 작동하는 모든 것이 있습니다. 내 버튼이 모든 이미지와 텍스트와 함께 올바르게 표시됩니다. 하지만 내 버튼에 마우스를 올리면됩니다. 나는 스타일과 스타일 트리거 마우스를 시도해 보았지만 어느 것도 효과가 없었다. 누군가 내 버튼 템플릿에 마우스를 가져 가면 아래에 나타나는 효과를 얻을 수 있다고 말해 줄 수 있습니까?XAML 단추 호버 효과

<Button Command="{Binding AppToolbarViewModel.RunToolAction, Source={StaticResource ViewModelLocator}}" CommandParameter="{Binding XamlURI}" ToolTip="{Binding ToolToolTip}" 
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Cursor="Hand"> 
    <Button.Template> 
    <ControlTemplate> 
     <StackPanel Orientation="Horizontal"> 
      <Grid> 
       <Label Content="&#xf0c8;" Style="{StaticResource FontAwesomeLabel}" /> 
       <Label Content="{Binding ImageURI}" Style="{StaticResource FontAwesomeLabel}" FontSize="20" Margin="10,10,0,0" Foreground="GhostWhite" /> 
      </Grid> 
      <Label Content="{Binding ToolName}" Style="{StaticResource ButtonLabel}" /> 
     </StackPanel> 
    </ControlTemplate> 
    </Button.Template> 
</Button> 

답변

0

미안하지만 (아직 50 명을 얻지는 못했지만) 호버 효과가 무엇인지 명확히 할 수 있습니까? 툴팁을 원하십니까? 아니면 스타일을 바꾸시겠습니까?

아무리 많은 툴팁이라도 참조하려면 http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868199.aspx 이미지를 추가 할 수 있습니다. 이미지를 툴팁으로 추가 할 수도 있습니다.

마우스를 가져 가면 스타일이 변경되도록하려면 "PointerEntered"및 "PointerExited"이벤트 처리기를 구현하고 코드 숨김 또는 다른 명령을 사용하여 스타일을 수정하면됩니다.

+0

답장을 보내 주셔서 감사합니다. 기본 효과 인 마우스가 단추 위에있을 때 변경할 배경을 찾고 있습니다. 내가 이해하는 한, 당신은 ControlTemplate을 사용할 때 그 효과를 잃어 버린다. 나는 그것을 되찾고 싶다. 가능하다면 완전한 XAML 솔루션을 원합니다. –

+0

VisualStateManager 클래스는 당신이 찾고있는 클래스라고 생각합니다. 100 % XAML이 아니지만 코드가 미미한 것은 아닙니다. http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager(v=vs.110).aspx –