XAML Windows:如何触发滑块的动画

时间:2015-01-20 12:48:43

标签: wpf visual-studio xaml

我认为这段代码应该是正确的,但动画永远不会开始。当画布加载时,我希望滑块继续前进到最大值然后反向。我正在使用Visual Studio。

    <Canvas>        
    <Canvas.Triggers>
        <EventTrigger RoutedEvent="Canvas.Loaded">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="Slider"
                            Storyboard.TargetProperty="Value"
                            From="50" To="100" AutoReverse="True" Duration="0:0:5"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger> 
    </Canvas.Triggers>
    <Slider x:Name="Slider" Width="300" Height="30"
            Maximum="100" Minimum="50"/>
   </Canvas>

0 个答案:

没有答案