当我尝试使用此代码启动我的应用时,它会抛出一个异常,说找不到错误文本。
<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>
看起来像路由事件属性有问题。什么会解决这个异常。
答案 0 :(得分:4)
我认为最好的方法是使用行为。它的目的是扩展基本控制的功能并结合可重用性。您可以在Windows blog上看到一个片段(我看到它在命名空间中的a part of the framework: Microsoft.Xaml.Interactions.Core 汇编:< Microsoft.Xaml.Interactions.dll中的strong> Microsoft.Xaml.Interactions 。
<Button x:Name="button">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Click">
<Media:ControlStoryboardAction Storyboard="storyboard1"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Button>