-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
AmbiguousMatchException when BindableProperty is hidden in a derived class and is then set in XAML #13962
Comments
@StephaneDelcroix Thoughts? |
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process. |
looks valid. SetValue doesn't set the c# property though, but the BP. But it still looks for the c# prop to get the type and attributes, and the ambiguous match comes from there |
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on android and windows platform with sample project. |
with XamlC disabled, setting an overriden property throws a AmbiguousMatchException. This fixes the mismatch between the 2 inflaters. - fixes #13962
with XamlC disabled, setting an overriden property throws a AmbiguousMatchException. This fixes the mismatch between the 2 inflaters. - fixes #13962
with XamlC disabled, setting an overriden property throws a AmbiguousMatchException. This fixes the mismatch between the 2 inflaters. - fixes #13962
with XamlC disabled, setting an overriden property throws a AmbiguousMatchException. This fixes the mismatch between the 2 inflaters. - fixes #13962
Description
Consider the following custom control which hides a BindableProperty:
Notice that the type of the new property (bool?) differs from that of the default property (bool).
When trying to set the new property in XAML, an AmbiguousMatchException is thrown with the following message:
"Multiple properties with name 'CustomCheckBox.IsChecked' found."
Setting the property in code-behind works as expected.
The exception seems to stem from the TrySetValue method of the ApplyPropertiesVisitor which uses the GetRuntimeProperty method. Actually, calling the method in the following manner is also sufficient to reproduce the exception:
Possible fix would be to use the GetRuntimeProperties method instead and then check the DeclaringType property to retrieve only a single property.
Note: Removing the "new" keyword does not resolve the exception.
Steps to Reproduce
Expected: The project runs successfully and the CheckBox is displayed.
Actual: The application crashes with an AmbiguousMatchException.
Link to public reproduction project repository
https://github.com/telerik/ms-samples/tree/main/Maui/HiddenBindableProperty
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
Windows SDK 10.0.19041.0, Android 33
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: