Reputation: 131
I created a custom control in Xamarin and it has a 2 way Bindable property.
public static BindableProperty SelectedItemsProperty =
BindableProperty.Create<MultiSelectList, IEnumerable>(o => o.SelectedItems, default(IEnumerable), BindingMode.TwoWay,
propertyChanged: OnSelectedItemsChanged);
public IEnumerable SelectedItems
{
get { return (IEnumerable)GetValue(SelectedItemsProperty); }
set { SetValue(SelectedItemsProperty, value); }
}
but the binding works only from ViewModel to the control. if the property value changes in the control it is not getting reflected in the viewmodel property that is bound to this. Just to be sure I assign new Ienumerable object whenever the property value changes inside the custom control. I am using Xamarin.Forms version 2.0.1.6505 Any help on how to force the binding from control to viewmodel?
Upvotes: 2
Views: 1689
Reputation: 1
You should use an ObservableCollection instead of IEnumerable. The ObservableCollection will refresh the UI when it changed, not IEnumerable.
Upvotes: 0