How to add animation to margin property of TextBlock in WPF

后端 未结 1 528
盖世英雄少女心
盖世英雄少女心 2021-01-28 14:55

I want to make TextBlock like this

\"margin

But,

aTextBlock.Begi         


        
相关标签:
1条回答
  • 2021-01-28 15:14

    You need to use ThicknessAnimation for this. DoubleAnimation is for properties of Double type.

    <TextBlock.Triggers>
        <EventTrigger RoutedEvent="TextBlock.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <ThicknessAnimation   
                        Storyboard.TargetName="TestB"
                        Storyboard.TargetProperty="(TextBlock.Margin)"
                        To="2" 
                        Duration="0:0:1" AutoReverse="True"
                        RepeatBehavior="2" />
                </Storyboard>
            </BeginStoryboard>
    
        </EventTrigger>
    </TextBlock.Triggers>
    
    0 讨论(0)
提交回复
热议问题