当我尝试使用此代码启动我的应用程序时,它会抛出一个异常,指出找不到错误文本。
<Button>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:05"
To="1" From="0"
Storyboard.TargetName="ContentGrid"
Storyboard.TargetProperty="Opacity" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
路由事件属性似乎有问题。什么将解决此异常。
最佳答案
我认为最好的方法是使用 Behavior。他们的目的是扩展与可重用性相结合的基本控件的功能。你可以在 Windows blog 上看到一个片段。 (正如我所见,它在命名空间中是 a part of the framework: Microsoft.Xaml.Interactions.Core 程序集: Microsoft.Xaml.Interactions 在 Microsoft.Xaml 中)。
<Button x:Name="button">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Media:ControlStoryboardAction Storyboard="storyboard1"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Button>
关于xaml - 单击按钮时触发 Storyboard?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36873211/