wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

NavigationItem wrongly activated

Open LasmGratel opened this issue 1 year ago • 0 comments

Describe the bug
NavigationItem has a weird behavior if two or more NavigationItem share the same PageType.

To Reproduce

<wpfui:NavigationFluent.Items>
    <wpfui:NavigationItem Tag="home" PageType="{x:Type pages:HomePage}">Home</wpfui:NavigationItem>
    <wpfui:NavigationItem Tag="edit-a.txt" PageType="{x:Type pages:EditorPage}">a.txt</wpfui:NavigationItem>
    <wpfui:NavigationItem Tag="edit-b.txt" PageType="{x:Type pages:EditorPage}">b.txt</wpfui:NavigationItem>
</wpfui:NavigationFluent.Items>

If you click on b.txt, "a.txt" will be activated. If they both called "a.txt", even with different tag, they will be activated.

Expected behavior
NavigationItem should be activated distinctly by its tag, not page type

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows 10]
  • .NET: [e.g. net5.0-windows10.0.17763.0]
  • Version: [e.g. 1.0.4-prerelease45]

Additional context
I want to learn more about how to add(and remove, if can) NavigationItem dynamically and inject ViewModels individually. An example is a text editor, you open a file, it creates a NavigationItem and navigate to the file.

In UWP, it is possible by overriding OnNavigatedTo(NavigationEventArgs e) and call e.Parameter.

Current PageService, NavigationService are too complicated to use, and not supporting navigation parameter.

LasmGratel avatar Jul 27 '22 06:07 LasmGratel