winui-3windows-template-studio

WInUI - Template Studio - Page Navigation - Stop page from sliding up


I've created a new project using "Template Studio for WinUI" extension project.

When navigating to a page, the page becomes visible and then slides up. I don't see any behavior that could be doing this.

Anyone know how to stop that?

Thanks


Solution

  • I guess you want to disable the animation transition that Frame offers for navigation. In order to do that, find the NavigateTo method in NavigationService (NavigationService.cs) and pass SuppressNavigationTransitionInfo to the Navigate method:

    public bool NavigateTo(string pageKey, object? parameter = null, bool clearNavigation = false)
    {
        var pageType = _pageService.GetPageType(pageKey);
    
        if (_frame != null && (_frame.Content?.GetType() != pageType || (parameter != null && !parameter.Equals(_lastParameterUsed))))
        {
            _frame.Tag = clearNavigation;
            var vmBeforeNavigation = _frame.GetPageViewModel();
    
            // HERE!
            var navigated = _frame.Navigate(
                pageType,
                parameter,
                new SuppressNavigationTransitionInfo());
    
            if (navigated)
            {
                _lastParameterUsed = parameter;
                if (vmBeforeNavigation is INavigationAware navigationAware)
                {
                    navigationAware.OnNavigatedFrom();
                }
            }
    
            return navigated;
        }
    
        return false;
    }