簡體   English   中英

在UWP中為頁面導航過渡創建自定義NavigationTransitionInfo

[英]Create customized NavigationTransitionInfo for Page Navigation Transitions in UWP

我正在開發通用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)
        {

        }
    }
}

實際上你可以在W10 Creators Update中實現這一點。 看看我剛剛在Twitter上發現的這篇博客文章

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM