I am trying to get the clicked item on my collection view (what a noble idea).
I am happy with the inner workings of my view:
<CollectionView SelectionChangedCommand="{Binding ClickCommand}" SelectionMode="Single" SelectionChangedCommandParameter="{Binding SelectedItem}" VerticalOptions="FillAndExpand" ItemsSource="{Binding WifiHotSpots}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
<Label Text="{Binding .}" FontAttributes="Bold" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
I am also happy with having the click being registered inside my command:
[RelayCommand]
public void Click(object obj)
{
}
... however, I am unhappy with my obj not containing anything. It is null.
How can I return the clicked item?
EDIT: The selected Item (which was just a test I believe):
private object _selectedItem;
public object SelectedItem
{
get { return _selectedItem; }
set
{
if (_selectedItem != value)
{
_selectedItem = value;
OnPropertyChanged(nameof(SelectedItem));
}
}
}
SelectedItem?SelectedItemis defined and how you set it.