Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top