. MouseOver
및 Normal
과 같이 다양한 상태에서 개체가 어떻게 보이는지, 그리고 여러 상태 간의 전환이 얼마나 오래되는지를 설명하기 만하면되며 시각 상태 관리자는 상태 간 전환 방법을 연구합니다.
이미지에 시각적 인 상태는 없지만 Button
템플릿을 편집하여 내용을 이미지로 만든 다음 버튼의 상태를 편집 할 수 있습니다. 나는이 일을하고 기술을 보여주기 위해 XAML 청소했습니다 : 그 혼합 당신을 위해 모든 작업을 수행
<Grid>
<Grid.Resources>
<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Image x:Name="image" Height="100" Width="Auto" Source="http://thecybershadow.net/misc/stackoverflow.png" Margin="0,0,-25,0">
<Image.Effect>
<DropShadowEffect ShadowDepth="0"/>
</Image.Effect>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.ShadowDepth)" Storyboard.TargetName="image">
<EasingDoubleKeyFrame KeyTime="0" Value="15"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Image>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Button Style="{StaticResource ButtonStyle1}"/>
</Grid>
참고하지만, XAML을 이해하는 데 도움이 될 것입니다. 여기에 혼합 지향 튜토리얼입니다 :
내가 Expression Blend를 사용하지 않는,하지만 어쩌면 당신은 직접 XAML에서 일하고 싶어? 다른 이벤트로 스토리 보드를 되돌리려면 가장 쉬운 방법은 애니메이션을 역순으로 수행하는 새로운 스토리 보드를 만들고 해당 이벤트에 태그를 지정하는 것입니다. –
그 일을 생각하고 있었지만 다른 스토리 보드를 만드는 것을 피하려고했습니다. 의견을 보내 주셔서 감사합니다. –
지금까지 "do-and-reverse"가 단일 이벤트에 의해 트리거되는 경우 쉽게 수행 할 수 있지만 ur의 경우에는 2 개의 개별 이벤트입니다. xaml만으로 편리한 방법을 알기를 바랍니다. –