[Solved] RadNavigationView hierarchical items lose expanded state after runtime theme change.

1 Answer 21 Views
NavigationView (Hamburger Menu)
Dodd
Top achievements
Rank 1
Dodd asked on 19 Jun 2026, 05:23 AM
I am building a NavigationView project where users can switch between multiple themes at runtime.

The NavigationView contains 5 navigation items in total, and 2 of them have hierarchical child items.

The initial theme works correctly.  
However, after running the application, if I select a child item in the hierarchy, for example `Products > Categories`, and then change the theme while that view is active, some issues occur.

The issues I observed are:

1. `RadNavigationView.SelectedItem` still appears to point to the child item `Categories`, but in the UI, the parent item appears collapsed, as if all expanded states were closed.
2. If issue 1 is resolved manually, the user may be able to click the item again with the mouse. However, I suspect that changing the theme with the keyboard arrow keys in the Theme ComboBox may behave differently from selecting a theme with the mouse.

I could not find a Telerik demo that shows how to handle runtime theme switching with a hierarchical `RadNavigationView`.

Could you help identify the cause of this behavior?  
Also, is there a recommended approach for preserving the selected item, expanded state, and item styles when changing themes at runtime in a hierarchical `RadNavigationView`?

I have attached a sample project. The license key has been removed.

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 19 Jun 2026, 02:25 PM

Hello, Dodd,

Thank you for providing a sample project that can demonstrate your current setup. I was able to revise it and would like to come up with the following thoughts:

The root cause of issue 1 is that RadNavigationViewItem.IsExpanded is not data-bound; when the ItemContainerStyle is swapped via DynamicResource, containers are regenerated with IsExpanded=false.

The root cause of issue 2 is that after the visual tree rebuild, the control needs a deferred reapplication of SelectedItem to visually highlight the child item again.

To resolve these, you should make the NavigationItem class observable so the IsExpanded property can notify the UI. I'll change it to derive from ObservableObject (already used in the project via CommunityToolkit.Mvvm):

Then add the IsExpanded property to NavigationItem (backed by ObservableObject) and bind it TwoWay in the ItemContainerStyle. This persists in the expanded state in the model so it survives container regeneration. Then, in MainViewModel, listen to ThemeChanged and use Dispatcher.BeginInvoke to reset SelectedNavigationItem after the visual tree rebuilds, ensuring the selection visual is restored. This also resolves the keyboard issue because each theme change (whether from mouse or keyboard) will properly restore state.

I updated the provided project with recent changes, so you can download it locally on your side and inspect how it works now. 

I hope this information helps. If you have other questions, please let me know.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Unlock smarter data exploration in RadGridView with AI-powered features. Enable natural language queries and help users uncover insights faster.

Learn more about RadGridView AI features

Dodd
Top achievements
Rank 1
commented on 22 Jun 2026, 12:27 PM

Hello Nadya,

Thank you for analyzing the cause of this issue and providing a solution.

I understand the changes, and I have confirmed that the updated project works correctly.

However, there is still one remaining issue. As I mentioned above, it works correctly with the mouse, but have you tried clicking the ComboBox and then using the keyboard Up/Down keys?

When I expand Categories and then use the keyboard, the expanded state is reset.

It seems that this may be caused by a difference between mouse event behavior and keyboard event behavior. How can this be resolved?

Separately, I accidentally created a duplicate post because I did not notice it at the time, but I cannot delete it myself. Is it possible to delete it, or should I just ignore it?

Thank you.

Martin Ivanov
Telerik team
commented on 25 Jun 2026, 01:29 PM

The issue seems to be related to a combination between a binding timing issue and keydown event propagation in the specific scenario. To resolve this, you delay the IsExpanded binding a bit. One way to do this is to use a global Loaded event handler RadNavigationViewItem and setup the binding there.

 static MainWindow()
 {
     EventManager.RegisterClassHandler(typeof(RadNavigationViewItem), RadNavigationViewItem.LoadedEvent, new RoutedEventHandler(OnRadNavigationViewItemLoaded));
 }

 private static void OnRadNavigationViewItemLoaded(object sender, RoutedEventArgs e)
 {
     var item = (RadNavigationViewItem)sender;
     item.SetBinding(RadNavigationViewItem.IsExpandedProperty, new Binding("IsExpanded") { Mode = BindingMode.TwoWay });
 }

I hope that helps.

Tags
NavigationView (Hamburger Menu)
Asked by
Dodd
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or