-
Notifications
You must be signed in to change notification settings - Fork 697
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
NavigationView.IsBackButtonVisible throws "value out of range" exception #8521
Comments
I get the same exception when assigning NavigationViewBackButtonVisible.Collapsed to a DependencyProperty that is registered with type NavigationViewBackButtonVisible, using the DependencyObject.SetValue method. The dependency property is bound OneWay with x:Bind to the IsBackButtonVisible property of the NavigationView. I am using net6.0-windows10.0.19041.0 The exception is: System.ArgumentException |
What is the value you set? |
I set it to Collapsed. I set it when the value was not already Collapsed. When the debugger breaks on the exception and I test the value it says that it is now set to Collapsed in the NavigationView. I am still narrowing it down but it appears that I set it from the constructor of a containing control (but after InitializeComponent) |
@sjb-sjb could you share a few line of codes to show exactly what's being assigned? Maybe it's a case of variable type, or something? Like, the string "Collapsed" may not be accepted, but |
I tried to narrow this down but without success. For the time being I have put an if test around the assignment to only allow the assignment if the assigned value is different from the current value. I am not sure this will work but will keep you posted if I find out anything further. |
The most I've got at the moment is this stack trace info: at WinRT.ExceptionHelpers.g__Throw|20_0(Int32 hr) at ABI.Microsoft.UI.Xaml.Controls.INavigationView2Methods.set_IsBackButtonVisible(IObjectReference _obj, NavigationViewBackButtonVisible value) Commenting that "IsBackButtonVisible" suggests boolean type while the actual type is an enum. Maybe there is an incorrectly declared variable somewhere in WinRT? I have checked and I am assigning the enum type. |
Okay. A Boolean does sound obvious. Where did you see it is a enum? |
It shows the enum in intellisense and also, of course, in the docs: https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.navigationview.isbackbuttonvisible?view=windows-app-sdk-1.3 Besides, how complicated can INavigationView2Methods.set_IsBackButtonVisible be? A reasonable chance that the problem is obvious if ine looks there. |
You're right, this looks like a bug. The enum is also mentioned https://learn.microsoft.com/windows/apps/design/controls/navigationview#backwards-navigation |
I was using a control template for the NavigationViewItemPresenter that was out of date. Not sure that this was the cause but it did cause some other problems. Given the difficulty reproducing, I suggest we close this. |
Describe the bug
I frequently encounter a "value out of range" exception when assigning to NavigationView.IsBackButtonVisible.
Steps to reproduce the bug
Assign a value to IsBackButtonVisible in code.
Expected behavior
Should not throw
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.3.1: 1.3.230502000
Windows version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: