2020-04-07 10:19:14 -07:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
2020-03-11 10:43:32 -07:00
|
|
|
|
|
2020-04-07 10:19:14 -07:00
|
|
|
|
using System;
|
2020-03-11 10:43:32 -07:00
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
|
|
|
|
|
{
|
2020-10-29 14:24:16 -07:00
|
|
|
|
public static class NavHelper
|
2020-03-11 10:43:32 -07:00
|
|
|
|
{
|
|
|
|
|
|
// This helper class allows to specify the page that will be shown when you click on a NavigationViewItem
|
|
|
|
|
|
//
|
|
|
|
|
|
// Usage in xaml:
|
|
|
|
|
|
// <winui:NavigationViewItem x:Uid="Shell_Main" Icon="Document" helpers:NavHelper.NavigateTo="views:MainPage" />
|
|
|
|
|
|
//
|
|
|
|
|
|
// Usage in code:
|
|
|
|
|
|
// NavHelper.SetNavigateTo(navigationViewItem, typeof(MainPage));
|
|
|
|
|
|
public static Type GetNavigateTo(NavigationViewItem item)
|
|
|
|
|
|
{
|
2020-10-29 14:24:16 -07:00
|
|
|
|
return (Type)item?.GetValue(NavigateToProperty);
|
2020-03-11 10:43:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void SetNavigateTo(NavigationViewItem item, Type value)
|
|
|
|
|
|
{
|
2020-10-29 14:24:16 -07:00
|
|
|
|
item?.SetValue(NavigateToProperty, value);
|
2020-03-11 10:43:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty NavigateToProperty =
|
|
|
|
|
|
DependencyProperty.RegisterAttached("NavigateTo", typeof(Type), typeof(NavHelper), new PropertyMetadata(null));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|