Navigation issue with dynamically added NavigationViewItem
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
I am trying to add a NavigationViewItem dynamically into the NavigationView. Its correctly showing the newly added item into the left navigation pane. but navigation service is not able to navigate by the TargetPageTag.
To Reproduce
var nav = _navigationService.GetNavigationControl();
var selected = nav.SelectedItem;
selected.MenuItems.Clear();
var mn = new NavigationViewItem()
{
Content = project.ProjectName,
Icon = new SymbolIcon { Symbol = SymbolRegular.TableLightning24 },
TargetPageType = typeof(ProjectPage),
TargetPageTag = "ProjectPage"
};
selected.MenuItems.Add(mn);
_navigationService.Navigate("ProjectPage");
Expected behavior
Navigation service should navigate to the newly added NavigationViewItem with the TargetPageTag
Screenshots
No response
OS version
Windows 11
.NET version
.net 8.0
WPF-UI NuGet version
3.0.4
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with a dynamically added NavigationViewItem on Windows 11 with .NET 8.0 and WPF-UI 3.0.4. Inspect how the navigation service resolves TargetPageTag values after the item is added; done means Navigate("ProjectPage") reaches ProjectPage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100