There is a ListView
of properties to select with Picker.
View:
<ViewCell.View>
<StackLayout>
<Picker ItemsSource="{Binding Values}" ItemDisplayBinding="{Binding Value}" SelectedItem="{Binding SelectedValue}" Title="{Binding Name}" />
</StackLayout>
</ViewCell.View>
ViewModel
ObservableCollection<VariableValue> _variableValues;
public ObservableCollection<VariableValue> Values
{
get { return _variableValues; }
set { SetProperty(ref _variableValues, value); }
}
private VariableValue _selectedValue;
public VariableValue SelectedValue
{
get { return _selectedValue; }
set
{
SetProperty(ref _selectedValue, value);
}
}
private string _name = "";
public string Name { get { return _name; } set { SetProperty(ref _name, value); } }
When select some item, it just changes SelectedValue
property
Selected item goes to SelectedValue
property
Then it comes again,
Then null
comes and changes _selectedValue
Then null
comes again
So it fires 4 times
@jassmith jassmith added p/Android t/bug labels 4 days ago
I am newbie in this project.
What does t/bug stand for?
@alexOffice Can you attach a minimalist reproduction project instead of just the code snippets?
Sorry if it's not minimal enough, made it with a default template
But it can be reproduced.
IssueReproduce.zip
Here is a place, where you can see the behavior with a break point, it fires multiple times
protected bool SetProperty<T>(ref T backingStore, T value,
[CallerMemberName]string propertyName = "",
Action onChanged = null)
{
if (EqualityComparer<T>.Default.Equals(backingStore, value))
return false;
backingStore = value;
onChanged?.Invoke();
OnPropertyChanged(propertyName);
return true;
}
Any progress?
@ansydor could you please check if the following issue is related to yours or even idential?
https://github.com/xamarin/Xamarin.Forms/issues/4390
It's work my project;
private var _selectedValue = new VariableValue();
public object SelectedValue
{
get { return _selectedValue; }
set
{
SetProperty(ref _selectedValue, value);
}
}
This issue doesn't seem to have had any activity in a long time. We're working on prioritizing issues and resolving them as quickly as we can. To help us get through the list, we would appreciate an update from you to let us know if this is still affecting you on the latest version of Xamarin.Forms, since it's possible that we may have resolved this as part of another related or duplicate issue. If we don't see any new activity on this issue in the next 30 days, we'll evaluate whether this issue should be closed. Thank you!
Since we haven't heard from you in more than 30 days, we hope this issue is no longer affecting you. If it is, please reopen this issue and provide the requested information so that we can look into it further. Thank you!
Most helpful comment
Sorry if it's not minimal enough, made it with a default template
But it can be reproduced.
IssueReproduce.zip