Closed Kcomid closed 4 years ago
@ranjeshj and @ojhad @llongley seems similar to the issue you saw a couple weeks ago. @Kcomid I don't think you are doing anything wrong.. This is probably a bug in the Navigation View's VSM
@Kcomid which version of WinUI are you using? There have been some recent fixes specifically this one. Could you try the latest pre-release ?
We are using Microsoft.UI.Xaml Version 2.4.2. I will try the pre-release and let you know. Thanks.
I have tried the new prerelease and things seem to be working better. Do you know when this will be released? I can’t use the prerelease in my project. Thank you.
@Kcomid I don't have a timeline yet for the next stable release. Most of the team is focused on WinUI3 at the moment.
@ranjeshj Is there any way around this for the time being in the 2.4 release?
@Going-Gone I just switched Xaml Controls Gallery to 2.4.3 and I can't reproduce the issue. If you can share a repro app, we can try to see what is different and if we can find a workaround. Just out of curiosity, Is there a reason you cannot use the pre-release ? Shipping production apps on pre-release WinUI2 versions is possible.
@ranjeshj Ah Will try 2.4.3. Didn't see that nuget version i guess. Was using 2.4.2 Thanks.
@ranjeshj Here is the repo. https://github.com/Going-Gone/NavViewWinUI2.4.2 The latest pre release works great. We may have to end up using it, but wanted to see if there was any work around first.
Issue still seems to be there in 2.4.3. Maybe I'm doing something wrong.
Simple expectation is The goal is to have the menu blue When selected white. If not selected blue.
I don't think it is an issue with your code. It does look like the bug that was fixed. The default colors have the same background for normal and pressed, so I'm guessing it repros there as well but just not visible. If you can update and ship on the pre-release that would be a better option. But If you absolutely cannot update, then this is a super hacky workaround to update the presenter visual state by hand.
private void NvMenu_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
{
foreach(var item in Headers)
{
var navItem = nvMenu.ContainerFromMenuItem(item) as Microsoft.UI.Xaml.Controls.NavigationViewItem;
if(!navItem.IsSelected)
{
var grid = VisualTreeHelper.GetChild(navItem, 0) as Grid;
if (grid != null)
{
var presenter = VisualTreeHelper.GetChild(grid, 0) as Microsoft.UI.Xaml.Controls.Primitives.NavigationViewItemPresenter;
if (presenter != null)
{
VisualStateManager.GoToState(presenter, "Normal", true);
}
}
}
}
}
It seems that this issue doesn't repro in the latest prerelease bits. @StephenLPeters @ranjeshj Is there anything to investigate here or can this be closed?
I don't think so, closing the issue, @Kcomid if there is still something wrong post back here and I'll reopen.
It appears to be working fine. My original concern was that it was in a prerelease versus an official release. Closing it is fine. If something changes I will let you know. Thanks.
Current XAML:
Visual Studio 2019 Enterprise Version 16.6.5 Target version: Windows 10, version 1903 (10.0; Build 18362) Min version: Windows 10, version 1809 (10.0; Build 17763)