microsoft / microsoft/microsoft-ui-xaml

NavigationView UI doesn't update when setting NavigationView.SelectedItem from code-behind

Open
#10,364 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-NavigationView bug needs-repro team-Controls
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When the NavigationView.Selecteditem is set in code behind, the NavigationViewraises an event as expected to show this has happened, and any interrigation of which item is selected is correct, but the UI selector dissapears, with no item showing as selected.

This is required for dynamically generated content where data binding is not possible

### Steps to reproduce the bug

Create a xaml NavigationView with items
Select an item in the UI - remember it in code
Select a different item in UI
Select the original selected item in code-behind - all works except the UI does not update

### Expected behavior

Regardless of how the currently selected item is selected, the UI should update

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.6.5: 1.6.250205002

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Reproduce the issue with a XAML NavigationView using Windows App SDK 1.6.5, selecting items first through the UI and then through code-behind, and trace the NavigationView control implementation and existing tests. Done means the selector remains visible and matches SelectedItem regardless of how selection changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.