I've just started working with Xamarin Forms and I'm trying to wrap my head around a couple of things that are (not) happening relating to a bound ListView, hopefully someone can shed some light on this for me.
private Item _SelectedItem; public Item SelectedItem; { get => _SelectedItem; set { _SelectedItem; = value; NotifyPropertyChanged("SelectedItem"); } } public ObservableCollection<Item> ItemsList { get; set; } public ICommand RemoveItemCommand { get; private set; } public MyViewModel() { RemoveItemCommand = new Command(RemoveItem, CanRemoveItem); } private void RemoveItem() { ItemsList.Remove(SelectedItem); } private bool CanRemoveItem() { return SelectedItem != null; //return true; }
And the Xaml:
When a row is selected there is no visual indication that it has been selected (ie. row is not highlighted)
When a row is selected, the SelectedItem property in my ViewModel contains the selected correct object, but the
CanRemoveItem property of the command is never set to true so the button is always disabled. However, RemoveItem method and button work when CanRemoveItem is manually set to true.
Is this expected behaviour or am I missing the mark somewhere?