我想在从一个UserControl导航到另一个UserControl时创建一些动画。它可以是任何简单的动画,就像我们在MS PowerPoint中有效果一样。
我该如何开始?
修改
让我们采取以下xaml
<StackPanel>
<Label>
<Hyperlink Click="ConfigureAccounts_Click">
<TextBlock>Configure Accounts</TextBlock>
</Hyperlink>
</Label>
<Label>
<Hyperlink Click="ConfigurePassangersList_Click">
<TextBlock>Accounts</TextBlock>
</Hyperlink>
</Label>
</StackPanel>
此处点击我正在进行的HyperLinks -
private void ConfigureAccounts_Click(object sender, RoutedEventArgs e)
{
ContentGrid.Children.Clear();
//Here is the animation
ContentGrid.Children.Add(new ConfigureAccounts());
}
private void ConfigurePassangersList_Click(object sender, RoutedEventArgs e)
{
ContentGrid.Children.Clear();
//Here is the animation
ContentGrid.Children.Add(new ConfigurePassangersList());
}
我调用的两个构造函数只是UserControls。
答案 0 :(得分:2)
WPF Bag of Tricks有一个TransitionPresenter
类,基本上是支持动画过渡的ContentPresenter
:
基本用法:
<bot:TransitionPresenter Content="{Binding SomeViewModelForWhichYouHaveADataTemplateDefined}">
<bot:TransitionPresenter.Transition>
<bot:FadeTransition Duration="00:00:00.3"/>
</bot:TransitionPresenter.Transition>
</bot:TransitionPresenter>
答案 1 :(得分:0)
你可以使用鼠标悬停选项..改变colours.it将是一个简单的开始。
我不会把它称为动画。如果你真的需要这个动画。你需要启动flash脚本动画。这是导航动画更好的一个。
希望这会有所帮助。 :)