你如何使用WPF框架控件做过渡效果? [英] How do you do transition effects using the Frame control in WPF?
问题描述
我想这将是容易的,但我不这样想。
I thought this would be easy but I guess not.
我有2页,在我的帧控制加载。我希望能够要么有
从一个页面一个不错的幻灯片效果下,或只是一个简单的淡入效果。
I have 2 pages that load in my frame control. I want to be able to either have a nice slide effect from one page to the next or just a simple fade-In effect.
似乎无法找到在这个互联网络的任何地方。
Can't seem to find this anywhere on the internets.
更新1
该接受的答案是好的,但我发现这里一个更好的。
<一href=\"http://www.japf.fr/2008/07/8/comment-page-1/\">http://www.japf.fr/2008/07/8/comment-page-1/
更新2
如果你能相信它,我发现了一个更好的解决方案。
HTTP://fluidkit.$c$cplex.com/
推荐答案
有是这里讨论了类似的问题:<一href=\"http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/eb477eee-3038-46e6-92a1-3b0ee621f1de\">Transition动画渐变当浏览到另一个页面使用说明那里你可以滑动技术 \\每一个新的页面导航的时间将您的帧控制。水木清华这样的:
There is a similar problem discussed here: Transition Fade Animation When Navigating To Page Using the technique described there you can slide\move your frame control each time a new page is navigated. Smth like this:
XAML:
...
<Frame Name = "frame" Navigating="frame_Navigating">
...
code:
...
private bool _allowDirectNavigation = false;
private NavigatingCancelEventArgs _navArgs = null;
private Duration _duration = new Duration(TimeSpan.FromSeconds(1));
private double _oldHeight = 0;
private void frame_Navigating(object sender, NavigatingCancelEventArgs e)
{
if (Content!=null && !_allowDirectNavigation)
{
e.Cancel = true;
_navArgs = e;
_oldHeight = frame.ActualHeight;
DoubleAnimation animation0 = new DoubleAnimation();
animation0.From = frame.ActualHeight;
animation0.To = 0;
animation0.Duration = _duration;
animation0.Completed += SlideCompleted;
frame.BeginAnimation(HeightProperty, animation0);
}
_allowDirectNavigation = false;
}
private void SlideCompleted(object sender, EventArgs e)
{
_allowDirectNavigation = true;
switch (_navArgs.NavigationMode)
{
case NavigationMode.New:
if (_navArgs.Uri == null)
frame.Navigate(_navArgs.Content);
else
frame.Navigate(_navArgs.Uri);
break;
case NavigationMode.Back:
frame.GoBack();
break;
case NavigationMode.Forward:
frame.GoForward();
break;
case NavigationMode.Refresh:
frame.Refresh();
break;
}
Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(ThreadStart)delegate()
{
DoubleAnimation animation0 = new DoubleAnimation();
animation0.From = 0;
animation0.To = _oldHeight;
animation0.Duration = _duration;
frame.BeginAnimation(HeightProperty, animation0);
});
}
...
希望这可以帮助,至于
hope this helps, regards
这篇关于你如何使用WPF框架控件做过渡效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!