在UWP中为页面导航过渡创建自定义NavigationTransitionInfo

时间:2017-03-18 20:16:48

标签: c# xaml uwp transitions

我正在开发通用Windows(UWP)应用程序,我想在页面中添加一些页面NavigationTransitions。 我知道我可以使用默认的NavigationThemeTransition,如下面的代码:

<Page.Transitions>
    <TransitionCollection>
        <NavigationThemeTransition>
            <NavigationThemeTransition.DefaultNavigationTransitionInfo>
                <CommonNavigationTransitionInfo/>
            </NavigationThemeTransition.DefaultNavigationTransitionInfo>
        </NavigationThemeTransition>
    </TransitionCollection>
</Page.Transitions>

但我想创建自己的导航过渡,我搜索了很多次但没有结果。 我也试图获得默认导航的定义,我能够编写如下代码,但不知道我必须在代码块中编写什么。有帮助吗?

  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Media.Animation;
  using Windows.UI.Xaml.Controls.Primitives;

  namespace BindingSample2
  {
    internal interface IWikiSedaNavigationTransitionInfo
    {
        System.Boolean IsStaggeringEnabled { get; set; }
    }
    public sealed class WikiSedaNavigationTransitionInfo : NavigationTransitionInfo, IWikiSedaNavigationTransitionInfo
    {
        //
        // Summary:
        //     Initializes a new instance of the WikiSedaNavigationTransitionInfo class.
        public WikiSedaNavigationTransitionInfo()
        {
            var a = this.GetNavigationStateCore();
            var s = this.MemberwiseClone();
            // NavigationThemeTransition theme = new NavigationThemeTransition();

            var themeR = new EdgeUIThemeTransition();

            themeR.Edge = EdgeTransitionLocation.Bottom;

            //Transitions = collection;
        }

        // Summary:
        //     Identifies the CommonNavigationTransitionInfo.IsStaggerElement attached property.
        //
        // Returns:
        //     The identifier for the CommonNavigationTransitionInfo.IsStaggerElement attached
        //     property.
        public static DependencyProperty IsStaggerElementProperty { get; }

        // Summary:
        //     Identifies the IsStaggeringEnabled dependency property.
        //
        // Returns:
        //     The identifier for the IsStaggeringEnabled dependency property.
        public static DependencyProperty IsStaggeringEnabledProperty { get; }

        // Summary:
        //     Gets or sets a Boolean value indicating if staggering is enabled for the navigation
        //     transition.
        //
        // Returns:
        //     A Boolean value indicating if staggering is enabled for the navigation transition.
        public System.Boolean IsStaggeringEnabled { get; set; }

        // Summary:
        //     Returns a Boolean value indicating if the specified UIElement is the stagger
        //     element for the navigation transition.
        //
        // Parameters:
        //   element:
        //     The UIElement to check as being the stagger element.
        //
        // Returns:
        //     Returns true if element is the stagger element; otherwise false.
        public static System.Boolean GetIsStaggerElement(UIElement element)
        {
            return false;
        }

        // Summary:
        //     Sets a Boolean value indicating if the specified UIElement is the stagger element
        //     for the navigation transition.
        //
        // Parameters:
        //   element:
        //     The UIElement about which to set the stagger element indicator.
        //
        //   value:
        //     Set this value to true if element is the stagger element; otherwise set it to
        //     false.
        public static void SetIsStaggerElement(UIElement element, System.Boolean value)
        {

        }
    }
}

1 个答案:

答案 0 :(得分:1)

实际上你可以在W10 Creators Update中实现这一点。看一下this blog post我刚刚找到on Twitter