wasteam / waslibs

Windows App Studio WinRT XAML & UWP Libraries
MIT License
313 stars 133 forks source link

Carousel ItemClick #48

Closed mashabek closed 8 years ago

mashabek commented 8 years ago

I was terribly upset that Carousel, ResponsiveGridView controls don't provide ItemClick event. It give us ItemClickCommand, but there is no need in it, because it I don't know what item was clicked. Will ItemClick event be available in near future?

javitosanchez commented 8 years ago

The controls you mentioned use the ICommand approach instead ItemClick approach. If you want to handle the item click event you have to expose a ICommand property in your viewModel. You can use the RelayCommand implementation that gives you the clicked item. For example:

public RelayCommand<ItemViewModel> ItemClickCommand
{
    get
    {
        return new RelayCommand<ItemViewModel>(
        (item) =>
        {
            // do whatever with your item
        });
    }
}
mashabek commented 8 years ago

That's great! I thought there is no CommandParameter, because Carousel provide only Command, but it seems included in ItemClickCommand.