WPF Button click Routed Event
-
06-07-2021 - |
题
I am getting the following error when trying to execute a button clcik event from xaml
<Button x:Name="myButton" Content="Surface History"
HorizontalAlignment="Right">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MyText"
Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Hello" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
<TextBox Name="MyText" Text="Hi"/>
Text
Storyboard.TargetProperty
path contains nonanimatable property Text
.
解决方案
Text property is Non Animatable dependency property. While creating the dependency property for Text, the UIMetaData IsAnimationProhibited property is set to true which prohibits the Text property to animate.
So Text property cannot be animated. You need to manually set the text from Timer to get this behaviour.
不隶属于 StackOverflow