You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
public static readonly BindableProperty SelectedValueProperty =
BindableProperty.Create(
nameof(SelectedValue),
typeof(T?),
typeof(EnumPicker<T>),
null,
BindingMode.TwoWay,
null,
propertyChanged: SelectedValue_Changed);
public T? SelectedValue
{
get => (T?)GetValue(SelectedValueProperty);
**set => SetValue(SelectedValueProperty, value);**
}
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: