-
-
Notifications
You must be signed in to change notification settings - Fork 291
Feature: Introducing BreadcrumbBar for page navigation #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Introducing BreadcrumbBar for page navigation #1046
Conversation
|
Okay so the issue is that, when using the Back button (in the window or on your mouse) |
Solved it |
Ah, thank you for solving this problem. This is exactly what I am thinking of (using a dictionary to match the parent page). But the current solution is definitely not what we should use. The current solution is more like a temporary solution. For example, the parent page is not always |
|
@ChenYiLins that's quite a change. Can you explain the changes for me, and maybe add some comments in the code? 😇 |
Good advice! I'll add a little note in a little bit! And explain. ( •̀ ω •́ )✧ @Jay-o-Way Because I have something to do today, maybe the explanation will come later tomorrow. I'm really sorry. |
|
@Jay-o-Way I'll briefly explain how I realized the function of BreadcrumbBar. First of all, I modified the original <NavigationViewItem
Content="{helpers:ResourceString Name=Time}"
Icon="{ui:FontIcon Glyph=}"
Tag="Time" />
<NavigationViewItem
Content="{helpers:ResourceString Name=SystemAreas}"
Icon="{ui:FontIcon Glyph=}"
Tag="SystemAreas" />(But the added Next is the query about the parent page. I added a dictionary to // Dictionary
private readonly Dictionary<string, Type> _pageParents = new();
// Query. If Null is returned, this page has no parent page.
public Type? GetPageParents(string key)
{
Type? pageType;
lock (_pageParents)
{
_pageParents.TryGetValue(key, out pageType);
}
return pageType;
}
// Matching
private void Matching<CV, PV>()
where CV : Page
where PV : Page
{
lock (_pageParents)
{
var key = typeof(CV).FullName!;
if (_pageParents.ContainsKey(key))
{
throw new ArgumentException($"The key {key} is already matched in PageService");
}
var type = typeof(PV);
_pageParents.Add(key, type);
}
}Get the parent page of the page through a loop and export it as a List. public List<Type> GetPageParentChain(string key)
{
var parentChain = new List<Type>();
var currentPageType = GetPageType(key);
while (currentPageType != null)
{
var parentType = GetPageParents(currentPageType.FullName!);
if (parentType != null)
{
parentChain.Insert(0, parentType);
currentPageType = parentType;
}
else
{
// No more parents found, exit the loop
break;
}
}
return parentChain;
}In private bool IsMenuItemForPageType(NavigationViewItem menuItem, Type sourcePageType)
{
if (menuItem.Tag is string pageKey)
{
pageKey = "AutoDarkModeApp.ViewModels." + pageKey + "ViewModel";
return _pageService.GetPageType(pageKey) == sourcePageType;
}
return false;
}This is basically about its complete realization. If you have any questions, please feel free to ask! |
Jay-o-Way
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha well I see you know alot more about this than I do 😅👍
The most important thing is that it works. So LGTM.
|
@ChenYiLins I see! So you're registering Pages that have a child via the Matching method instead of Configure in the PageService that we already use to resolve the navigation path, allowing you to recall the history for each option. Nice solution! |
Spiritreader
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brotkrumen
Exakt |
Description
Use BreadcrumbBar to navigate between pages.
Screenshots