基于在包含UserControl(名为“UserControl”)上定义的属性IsInteracting的值,我有一个WPF控件,我想动画。我在UserControl中定义了以下样式,动画定位在UserControl中定义的网格。当另一个控件上的属性发生变化时启动WPF动画
<UserControl.Resources>
<Style TargetType="Grid">
<Setter Property="Opacity" Value="0" />
<Setter Property="Height" Value=""></Setter>
<Style.Triggers>
<Trigger Property="IsInteracting" Value="True" SourceName="UserControl">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames
Storyboard.Target="{Binding ElementName=ControlGrid}"
Storyboard.TargetProperty="Opacity"
>
<EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
这不起作用,因为名称“UserControl”无法识别。我认为有一些范围问题妨碍了风格之外的元素的引用?
我该怎么做我想做的事?