在按钮上调用不同xaml控件中的动画单击而不依赖于ViewModels

时间:2017-05-03 05:17:44

标签: c# wpf xaml

我有以下xaml:

<Button Content="{Binding Header}" Background="Blue" Name="PanelHeader">
                        <Button.Triggers>
                            <EventTrigger RoutedEvent="Button.Click">
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="Stackpanel"
                                      Storyboard.TargetProperty="Height"
                                      From="0" To="100" Duration="0:0:3" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </Button.Triggers>
                    </Button>

我想将故事板动画移动到堆栈面板声明,只需从按钮单击调用该动画。

我发现大多数示例都使用了viewmodel或其他代码隐藏的插入方式。

1 个答案:

答案 0 :(得分:0)