大家好,
我采用的FluidKit.dll到我的应用程序得到一个漂亮的幻灯片过渡效果/我的窗口,页面和usercontrols。现在我已经工作,但它似乎是动画开始变得有点生涩时,有一个过渡页面的更多信息。我读过一点点,看来,我可以在转换的流动性,帮助实施RenderTargetBitmap功能在我的内容演示。
有谁知道如何做到这一点,或有对我来说是很好的指针?下面是我使用的ContentPresenter代码:
public class NavigationPresenter : ContentPresenter
{
private readonly ContentPresenter oldContentPresenter;
private readonly ContentPresenter newContentPresenter;
private readonly TransitionPresenter transitionPresenter;
private bool loaded;
#region GoForward
/// <summary>
/// GoForward Dependency Property
/// </summary>
public static readonly DependencyProperty GoForwardProperty;
/// <summary>
/// Gets or sets the GoForward property
/// </summary>
public bool GoForward
{
get { return (bool)GetValue(GoForwardProperty); }
set { SetValue(GoForwardProperty, value); }
}
#endregion
#region Transition
/// <summary>
/// Transition Dependency Property
/// </summary>
public static readonly DependencyProperty TransitionProperty;
/// <summary>
/// Gets or sets the Transition property
/// </summary>
public Transition Transition
{
get { return (Transition)GetValue(TransitionProperty); }
set { SetValue(TransitionProperty, value); }
}
#endregion
internal UIElementCollection Children
{
get;
private set;
}
static NavigationPresenter()
{
GoForwardProperty = DependencyProperty.Register(
"GoForward",
typeof(bool),
typeof(NavigationPresenter),
new FrameworkPropertyMetadata(false));
TransitionProperty = DependencyProperty.Register(
"Transition",
typeof(Transition),
typeof(NavigationPresenter),
new FrameworkPropertyMetadata(new NavigationCubeTransition(), new PropertyChangedCallback(OnTransitionChanged)));
ContentProperty.OverrideMetadata(
typeof(NavigationPresenter),
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnContentValueChanged)));
}
public NavigationPresenter()
{
this.oldContentPresenter = new ContentPresenter();
this.newContentPresenter = new ContentPresenter();
this.transitionPresenter = new TransitionPresenter();
this.transitionPresenter.Items.Add(this.oldContentPresenter);
this.transitionPresenter.Items.Add(this.newContentPresenter);
this.Children = new UIElementCollection(this, null);
this.Children.Add(this.transitionPresenter);
this.Loaded += (s, e) => this.loaded = true;
}
private static void OnTransitionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((NavigationPresenter)d).OnTransitionChanged(e);
}
private static void OnContentValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((NavigationPresenter)d).OnContentValueChanged(e);
}
private void OnContentValueChanged(DependencyPropertyChangedEventArgs e)
{
// switch ContentPresenters
this.oldContentPresenter.Content = e.OldValue;
this.newContentPresenter.Content = e.NewValue;
if (this.loaded)
{
// if the transition supports the INavigationAware interface
// prepare it using the GoForward/GoBackward methods
if (this.transitionPresenter.Transition is INavigationAware)
{
if (this.GoForward)
((INavigationAware)this.transitionPresenter.Transition).GoForward();
else
((INavigationAware)this.transitionPresenter.Transition).GoBackward();
}
// run the transition
this.transitionPresenter.ApplyTransition(this.oldContentPresenter, this.newContentPresenter);
}
}
private void OnTransitionChanged(DependencyPropertyChangedEventArgs e)
{
this.transitionPresenter.Transition = e.NewValue as Transition;
}
//TODO: try converting to RenderTargetBitmap
protected override Visual GetVisualChild(int index)
{
if ((index < 0) || (index >= this.Children.Count))
throw new ArgumentOutOfRangeException("index");
return this.Children[index];
}
protected override int VisualChildrenCount
{
get
{
if (this.Children != null)
return