-
Notifications
You must be signed in to change notification settings - Fork 38
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] Set nullable BindableProperty to null throws Exception #354
Comments
I have the exact same issue. |
Same problem here. E.g. binding the SelectedItemProperty of an CollectionView. |
We also ran into this issue. Will this be addressed? For us this is a breaking change when migrating to .net9.0 and thus also upgrading to CommunityToolkit 10+. Not sure what's causing this and why this is happening? |
You shouldn't wait - this seems to be a lost place that is not visited for 4 months. Get the repo and add the project to your solution. Change the line described above. |
If you know the fix please feel free to contribute a Pull Request and give back to the toolkit |
Ok, i didn't know i have the rights. I'll try. |
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
Setting a bindable and nullable property to null throws an exception "Unable to find target value".
Expected Behavior
should be ok
this worked in "CommunityToolkit.Maui.Markup" Version="4.2.0"
Steps To Reproduce
In my case, the problem occurs in a special control.
The control is defined in nullable environment with generic struct to let a enum picker be set to null.
public partial class EnumPicker : Picker where T : struct, Enum //allow null with struct
...
the property is defined:
The control is used at a contenview:
After giving the Selected Value an enum value and set it back to null, the exception will be thrown at
set => SetValue(SelectedValueProperty, value);
Link to public reproduction project repository
hope this is not needed
Environment
Anything else?
Remove the exception throw in your TypedBinding.cs, Line 249:
var value = GetTargetValue(target.GetValue(property), typeof(TProperty))/* ?? throw new InvalidOperationException("Unable to find target value")*/;
returning a null is not a fault here. For my use, after removing the exception, it works than as it should.
More testing makes no sense for me, because i don't know the intention of throwing this exception here.
The text was updated successfully, but these errors were encountered: