I am currently creating a NavigationViewItem and add it to an existing NavigationView. After that i want to navigate to it.
NavigationViewItem item = new NavigationViewItem() {/*...*/};
NavView.MenuItems.Add(item);
ContentFrame.Navigate(typeof(Project), item);
var menuItem = NavView.MenuItems
.OfType<NavigationViewItem>()
.Where(item => item.Tag.ToString() == tag)
.First();
NavView.SelectedItem = menuItem;
But after i add it to the list and select the menu item, it still does the "adding"-animation, so it doesn't trigger the "active menu-item" animation or rather the (blue) indicator on the left side:
So in the end, the indicator is missing. Clicking on the menu item again also doesn't make it appear, only after navigating away from it.
Just tested your code and it indeed makes that "worm-like" animation for the item "pipe" as it adds the item to the menu.
Here's a simple approach but don't know if this is a good code but somehow worked for me.
await Task.Delay(500);
Added the code after adding the item and before selecting that item.
EDIT:
NavigationViewItem item = new NavigationViewItem() { ... };
nvMain.MenuItems.Add(item);
await Task.Delay(500);
SelectAddedItem(item); //Method to select the item
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.