Hello,
I get a cast error when trying to send my selected listviewitem with RelayCommand. I'm using the galasoft mvvm RelayCommand.
Error.
System.InvalidCastException: Unable to cast object of type 'Windows.UI.Xaml.Controls.ItemClickEventArgs' to type 'utmaningen.Models.CatModel'.
at GalaSoft.MvvmLight.Command.RelayCommand`1.Execute(Object parameter)
at Microsoft.Xaml.Interactions.Core.InvokeCommandAction.Execute(Object sender, Object parameter)
at Microsoft.Xaml.Interactivity.Interaction.ExecuteActions(Object sender, ActionCollection actions, Object parameter)
at Microsoft.Xaml.Interactions.Core.EventTriggerBehavior.OnEven
MainPage.xaml
<Core:InvokeCommandAction Command="{Binding RelayCmd}"
CommandParameter="{Binding ElementName=CatsListview, Path=SelectedCat}"/>
CatsViewModel.cs
private RelayCommand<CatModel> _executeRelayCmd;
public RelayCommand<CatModel> RelayCmd
{
get
{
return _executeRelayCmd?? (_executeRelayCmd= new RelayCommand<CatModel>(ExecuteCatCommand));
}
}
public void ExecuteCatCommand(CatModel _executeRelayCmd)
{
//Want to get my listview selection info.
}