mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Added in generic ViewModel
This commit is contained in:
committed by
Lavius Motileng
parent
e2c7941542
commit
3f5a54f9f1
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||
{
|
||||
public class NavHelper
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
return (Type)item.GetValue(NavigateToProperty);
|
||||
}
|
||||
|
||||
public static void SetNavigateTo(NavigationViewItem item, Type value)
|
||||
{
|
||||
item.SetValue(NavigateToProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty NavigateToProperty =
|
||||
DependencyProperty.RegisterAttached("NavigateTo", typeof(Type), typeof(NavHelper), new PropertyMetadata(null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user