UI.WPF.Modern
UI.WPF.Modern copied to clipboard
fix(Gallery): Fix navigation state mismatch and lost selection on search results page
Description
This pull request fixes core navigation state anomalies in the Gallery sample project, improves the robustness of the navigation logic, and syncs the latest code from the upstream main branch, with no breaking changes introduced.
Key Fixes & Improvements
- Fixed navigation state conflict risks: Refactored the page type validation logic in the
OnRootFrameNavigatedmethod, replacing independentifbranches with a sequential, mutually exclusiveif-else ifstructure. This prevents duplicate branch execution and repeated value assignment that could lead to state conflicts during a single navigation operation. - Completed search results page state handling: Added a dedicated conditional branch for
SearchResultsPageto properly record the page type to_lastItem, resolving the bug where the NavigationView selected item is lost or mismatched when navigating to/from the search results page via forward/backward operations. - Optimized special page handling priority: Moved the
SettingsPagevalidation branch to the front of the logic flow, prioritizing handling for special pages without corresponding navigation menu items, and preventing state from being incorrectly overwritten by subsequent branches. - Synced upstream baseline: Merged the latest code from the
iNKORE-NET:mainbranch to resolve branch differences and ensure this PR can be merged without conflicts.
Impact Scope
Only modifies the navigation root page code of the iNKORE.UI.WPF.Modern.Gallery sample project. No changes to the core library source code, no API alterations, and no breaking changes.
Validation & Testing
- Verified navigation and backward/forward operations between the Settings Page and home/control pages, with NavigationView selection state syncing correctly
- Verified navigation between the Search Results Page and other pages, with no selection mismatch or loss occurring
- Validated original navigation logic for the All Controls Page, New Controls Page, and Section Pages, with no regression issues
- Tested continuous navigation and backward operations across multiple pages, with navigation state remaining consistent and correct throughout the process