-
Notifications
You must be signed in to change notification settings - Fork 663
/
Copy pathNavigationOrientationHelper.cs
57 lines (51 loc) · 1.5 KB
/
NavigationOrientationHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.Storage;
using WinUIGallery.Pages;
namespace WinUIGallery.Helpers;
public static class NavigationOrientationHelper
{
private const string IsLeftModeKey = "NavigationIsOnLeftMode";
private static bool _isLeftMode = true;
public static bool IsLeftMode()
{
if (NativeHelper.IsAppPackaged)
{
var valueFromSettings = ApplicationData.Current.LocalSettings.Values[IsLeftModeKey];
if (valueFromSettings == null)
{
ApplicationData.Current.LocalSettings.Values[IsLeftModeKey] = true;
valueFromSettings = true;
}
return (bool)valueFromSettings;
}
else
{
return _isLeftMode;
}
}
public static void IsLeftModeForElement(bool isLeftMode)
{
UpdateNavigationViewForElement(isLeftMode);
if (NativeHelper.IsAppPackaged)
{
ApplicationData.Current.LocalSettings.Values[IsLeftModeKey] = isLeftMode;
}
else
{
_isLeftMode = isLeftMode;
}
}
public static void UpdateNavigationViewForElement(bool isLeftMode)
{
NavigationView _navView = App.MainWindow.NavigationView;
if (isLeftMode)
{
_navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Auto;
}
else
{
_navView.PaneDisplayMode = NavigationViewPaneDisplayMode.Top;
}
}
}