我在单个样式的每个EventTrigger中需要不同类型的转换,只使用RenderTransform属性的一个值就可以正常工作:
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1" ScaleY="1"/>
</Setter.Value>
</Setter>
但是当我尝试这个时:
<Setter Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Setter.Value>
</Setter>
我甚至无法访问TargetProperty中的单个属性,它的全部样式是这样的:
<Style TargetType="k:KinectTileButton" x:Key="BotonTutorial">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderThickness" Value="6"/>
<Setter Property="ToolTip" Value="Empuja para seleccionar"/>
<Setter Property="Height" Value="400"/>
<Setter Property="Width" Value="250"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="k:KinectTileButton.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(k:KinectTileButton.RenderTransform).(TranslateTransform.Y)" From="-50" To="0" Duration="0:0:1">
<DoubleAnimation.EasingFunction>
<CircleEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<!--More events-->
<EventTrigger RoutedEvent="k:KinectTileButton.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(k:KinectTileButton.Background).(SolidColorBrush.Color)" To="White" Duration="0:0:0.1" FillBehavior="HoldEnd"/>
<DoubleAnimation Storyboard.TargetProperty="(k:KinectTileButton.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="1.3" Duration="0:0:0.5" FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimation Storyboard.TargetProperty="(k:KinectTileButton.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="1.3" Duration="0:0:0.5" FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<!--End of the style-->
如果没有TransformGroup,我只能使用一个值或转换,因此只有一个触发器可以工作,我知道在添加按钮时添加这些值会更容易,但这将适用于很多按钮。 / p>
答案 0 :(得分:0)
动画的TargetProperty值应引用TransformGroup的Children
集合,并且不应有k:KinectTileButton
之类的名称前缀:
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].ScaleX" ...>
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].ScaleY" ...>
...
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[1].Y" ...>