c# - 在 UWP 中为页面导航转换创建自定义 NavigationTransitionInfo

标签 c# xaml uwp transitions

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

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

但是我想创建自己的Navigation Transition,我搜索了很多次都没有结果。 我还尝试获取默认导航的定义,并且能够编写如下代码,但不知道必须在代码块中编写什么。有什么帮助吗?

  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 中实现这一目标。看看this blog post我刚找到 on Twitter .

关于c# - 在 UWP 中为页面导航转换创建自定义 NavigationTransitionInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42879367/

相关文章:

c# - 如何读取当前使用的文件,就像 Windows 在复制文件时所做的那样?

c# - 如何避免级联错误消息

silverlight - ItemsControl,ItemsPanel和ItemsPresenter(Silverlight,XAML)

c# - UWP 中的 InkCanvas MVVM 绑定(bind)

c# - 如何在不引用数组的情况下更改数组对象?

c# - WPF - 从 UserControl 操作 VisualState

unit-testing - 从命令行运行通用 Windows 单元测试

c# - UWP HttpRequestMessage.TransportInformation 缺失

c# - iFrame 在 asp AjaxToolkit TabContainer 中加载两次

xaml - 你如何在屏幕中央放置一个正方形(使用 xaml)