diff --git a/dev/DevWinUI/Services/NavigationService/Services/DataSource.cs b/dev/DevWinUI/Services/NavigationService/Services/DataSource.cs index ecb8048..00bdfe3 100644 --- a/dev/DevWinUI/Services/NavigationService/Services/DataSource.cs +++ b/dev/DevWinUI/Services/NavigationService/Services/DataSource.cs @@ -56,19 +56,6 @@ public async Task> GetGroupsAsync(string jsonFilePath, Pa return _instance.Groups; } - - /// - /// Load Assets\NavViewMenu\AppData.json - /// - /// - public async Task> GetGroupsAsync() - { - _jsonFilePath = @"Assets\NavViewMenu\AppData.json"; - _pathType = PathType.Relative; - await _instance.GetControlInfoDataAsync(); - - return _instance.Groups; - } public static async Task GetGroupAsync(string uniqueId) { @@ -170,4 +157,4 @@ public static async Task LoadText(string filePath, PathType pathType) } return await FileIO.ReadTextAsync(file); } -} \ No newline at end of file +} diff --git a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Builder.cs b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Builder.cs index a9de138..f7b6179 100644 --- a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Builder.cs +++ b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Builder.cs @@ -20,21 +20,24 @@ public JsonNavigationService ConfigureJsonFile(string jsonFilePath, PathType pat ConfigJsonBase(jsonFilePath, pathType, orderItems); return this; } - + public JsonNavigationService ConfigureJsonFile() + { + EnsureInitialized(); + ConfigJsonBase(@"Assets\NavViewMenu\AppData.json", PathType.Relative, OrderItemsType.AscendingTopLevel); + return this; + } public JsonNavigationService ConfigureJsonFile(string jsonFilePath) { EnsureInitialized(); ConfigJsonBase(jsonFilePath, PathType.Relative, OrderItemsType.AscendingTopLevel); return this; } - public JsonNavigationService ConfigureJsonFile(string jsonFilePath, OrderItemsType orderItems) { EnsureInitialized(); ConfigJsonBase(jsonFilePath, PathType.Relative, orderItems); return this; } - public JsonNavigationService ConfigureJsonFile(string jsonFilePath, PathType pathType) { EnsureInitialized(); diff --git a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Configs.cs b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Configs.cs index afa1d20..ca2fb6b 100644 --- a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Configs.cs +++ b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.Configs.cs @@ -8,11 +8,9 @@ public partial class JsonNavigationService private async void ConfigJsonBase(string jsonFilePath, PathType pathType, OrderItemsType orderItems) { JsonFilePath = jsonFilePath; - await DataSource.Instance.GetGroupsAsync(); + await DataSource.Instance.GetGroupsAsync(jsonFilePath, pathType); AddNavigationMenuItems(orderItems); - - EnsureNavigationSelection(_defaultPage?.ToString()); } private void ConfigAutoSuggestBox(AutoSuggestBox autoSuggestBox, bool useItemTemplate = true, string autoSuggestBoxNotFoundString = null, string autoSuggestBoxNotFoundImagePath = null) diff --git a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.NavigationView.cs b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.NavigationView.cs index 56757e9..6ee4320 100644 --- a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.NavigationView.cs +++ b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.NavigationView.cs @@ -91,6 +91,8 @@ private void AddNavigationMenuItems(OrderItemsType orderItems) } } } + + EnsureNavigationSelection(_defaultPage?.ToString()); } private IEnumerable GetOrderedDataGroups(OrderItemsType orderItems) diff --git a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.cs b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.cs index a6824be..9ccb65b 100644 --- a/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.cs +++ b/dev/DevWinUI/Services/NavigationService/Services/JsonNavigationService/JsonNavigationService.cs @@ -12,10 +12,10 @@ private void InitializeBase(NavigationView navigationView, Frame frame, Dictiona this.Frame = frame ?? throw new ArgumentNullException(nameof(frame)); this._pageKeyToTypeMap = pages ?? throw new ArgumentNullException(nameof(pages)); - _navigationView.BackRequested -= OnBackRequested; - _navigationView.BackRequested += OnBackRequested; - _navigationView.SelectionChanged -= OnSelectionChanged; - _navigationView.SelectionChanged += OnSelectionChanged; + _navigationView.BackRequested -= OnNavigationViewBackRequested; + _navigationView.BackRequested += OnNavigationViewBackRequested; + _navigationView.SelectionChanged -= OnNavigationViewSelectionChanged; + _navigationView.SelectionChanged += OnNavigationViewSelectionChanged; var settingItem = (NavigationViewItem)SettingsItem; if (settingItem != null) @@ -26,6 +26,7 @@ private void InitializeBase(NavigationView navigationView, Frame frame, Dictiona FrameNavigated -= OnNavigated; FrameNavigated += OnNavigated; } + private void OnNavigated(object sender, NavigationEventArgs e) { _navigationView.IsBackEnabled = CanGoBack; @@ -56,8 +57,8 @@ public void Reset() { _navigationView.MenuItems?.Clear(); _navigationView.FooterMenuItems?.Clear(); - _navigationView.BackRequested -= OnBackRequested; - _navigationView.SelectionChanged -= OnSelectionChanged; + _navigationView.BackRequested -= OnNavigationViewBackRequested; + _navigationView.SelectionChanged -= OnNavigationViewSelectionChanged; } _pageKeyToTypeMap?.Clear(); @@ -67,7 +68,7 @@ public void Reset() Frame = null; } - private void OnSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) + private void OnNavigationViewSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { if (args.IsSettingsSelected) { @@ -103,12 +104,12 @@ public void UnregisterEvents() { if (_navigationView != null) { - _navigationView.BackRequested -= OnBackRequested; - _navigationView.SelectionChanged -= OnSelectionChanged; + _navigationView.BackRequested -= OnNavigationViewBackRequested; + _navigationView.SelectionChanged -= OnNavigationViewSelectionChanged; } } - private void OnBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) => GoBack(); + private void OnNavigationViewBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) => GoBack(); private void OnAutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) {