如何在wpf中加载带动画的页面 [英] How do I load Page with animation in wpf
本文介绍了如何在wpf中加载带动画的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai
我想用动画加载页面
我用这段代码
Hai
I want to load page with animation
I use this code
<window.resources>
<!-- Slide and Fade -->
<storyboard x:key="SlideAndFadeIn" xmlns:x="#unknown">
<thicknessanimation duration="0:0:.75"
Storyboard.TargetProperty="Margin"
From="500,0,-500,0"
To="0"
DecelerationRatio=".9" />
<doubleanimation duration="0:0:.25"
Storyboard.TargetProperty="Opacity"
From="0"
To="1" />
</storyboard>
</window.resources>
<Frame x:Name="Mframe" Content="Frame" Grid.Row="1" NavigationUIVisibility="Hidden" Navigating="Mframe_Navigating" HorizontalAlignment="Right" Height="799" VerticalAlignment="Bottom" Width="1432" RenderTransformOrigin="0.5,0.5">
<Frame.RenderTransform>
<transformgroup>
</transformgroup>
</Frame.RenderTransform>
<Frame.Background>
<lineargradientbrush endpoint="0.5,1" startpoint="0.5,0">
<gradientstop color="Black" offset="0" />
<gradientstop color="White" offset="1" />
</lineargradientbrush>
</Frame.Background>
</Frame>
在Mainform中
And in Mainform
Private Sub RibbonMenuItem_Click(sender As Object, e As RoutedEventArgs)
Mframe.Content = New PageReport()
'Mframe.Source = New Uri("CupPage.xaml", UriKind.RelativeOrAbsolute)
End Sub
Private Sub RibbonButton_Click(sender As Object, e As RoutedEventArgs)
Mframe.Content = New CupPage()
End Sub
Private Sub Mframe_Navigating(sender As Object, e As NavigatingCancelEventArgs) Handles Mframe.Navigating
Dim s As Storyboard = CType(TryFindResource("Mframe"), Storyboard)
s.Begin()
End Sub
这显示错误(s.Begin())
请告诉我什么是错的或者请告诉我如何加载带动画的页面。
谢谢
this shows error (s.Begin())
please tell me whats wrong or Pls Tell me how to load a page with animation.
thanks
推荐答案
参考以下链接,
1. wpf - 如何为窗口设置动画? - Stack Overflow [ ^ ]
2. http://www.codeguru.com/csharp/.net/net_wpf/article.php/c17649/Animations-in-Windows-Presentation-Foundation-WPF.htm [ ^ ]
您可以使用 MahApps.Metro 框架,它有窗口和页面的内置动画效果。
Hi, refer the below links,
1. wpf - How to animate a Window? - Stack Overflow[^]
2. http://www.codeguru.com/csharp/.net/net_wpf/article.php/c17649/Animations-in-Windows-Presentation-Foundation-WPF.htm[^]
And you can use MahApps.Metro framework, it has inbuilt animation effects for Window and Pages.
这篇关于如何在wpf中加载带动画的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文