Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG and REGRESSION: Custom NavigationViewItem crashes app at startup #8814

Closed
knightmeister opened this issue Aug 31, 2023 · 2 comments
Closed
Labels
area-NavigationView NavView control bug Something isn't working closed-Fixed Described behavior has been fixed. team-Controls Issue for the Controls team
Milestone

Comments

@knightmeister
Copy link

Describe the bug

Firstly, I have spent considerable time investigating this and pinpointing the cause of this issue. Please don't arbitrarily close this without investigating it.

Between WASDK 1.1.5 and 1.2.221109.1 there is a regression that crashes my app at startup. My NavigationView uses custom NavigationViewItems (called HomeMenuItem). Setting the NavigationView property SelectedItem to this at startup will cause the app to crash with a nonsensical error Value does not fall within the expected range. in everybodies favourite useless block of code:

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
            UnhandledException += (sender, e) =>
            {
                if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
            };
#endif

Interestingly, if the ctor assignment of SelectedItem is commented and it's done later (i.e. via a button), it works.

To further elucidate on the cause, overriding the HomeMenuItem template (i.e. by setting Content="Hello") in the XAML stops this bug.

The fact that this behaviour occurs during startup is also interesting but works once the app is displayed. It's also clearly a regression given it works in 1.1.5 and earlier (code has been in place since before WASDK).

Please reach out if you need anything further :)

Steps to reproduce the bug

Github repro available here: https://github.com/knightmeister/WinUiNavViewCooked

Change the Nuget WASDK version to 1.1.5 and observe it works. Anything after that (including the latest) does not work.

Expected behavior

App does not crash when using custom NavigationViewItem.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.4.0: 1.4.230822000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@knightmeister knightmeister added the bug Something isn't working label Aug 31, 2023
@bpulliam bpulliam added area-NavigationView NavView control team-Controls Issue for the Controls team labels Sep 7, 2023
@llongley llongley added the closed-Fixed Described behavior has been fixed. label Jan 20, 2024
@knightmeister
Copy link
Author

@llongley any idea what release this will make it into?

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 20, 2024
@codendone codendone added this to the WinAppSDK 1.5 milestone Jan 21, 2024
@codendone codendone removed the needs-triage Issue needs to be triaged by the area owners label Jan 21, 2024
@codendone
Copy link
Contributor

@knightmeister The fix will be in 1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NavigationView NavView control bug Something isn't working closed-Fixed Described behavior has been fixed. team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

4 participants