I am developing first app using MVVM. I have followed this link for navigation. In answer from Lawrence A. Contreras I used the first approach for navigation but I receive Command not found error. My code is
<ListView x:Name="lstItem" Grid.Row="1" ItemsSource="{Binding OrdersObject.data.orders}" ItemTemplate="{StaticResource DueOrderTemplate}" ItemContainerStyle="{StaticResource StretchItemStyle}">
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="SelectionChanged">
<Core:InvokeCommandAction CommandParameter="{Binding SelectedItem, ElementName=lstItem}" Command="{Binding SelectedOrderCommand}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</ListView>
and cs is
var OrdersObj = new ViewModels.OrdersVM();
OrdersObj.SelectedOrderCommand = new RelayCommand<Models.OOrderM>((itemParam) =>
{
if (itemParam != null)
this.Frame.Navigate(typeof(OrderEditP), itemParam);
});
await OrdersObj.GetOrders("pending");
this.DataContext = OrdersObj;
and my View Model is
class OrdersVM
{
RelayCommand<OOrderM> _slectedOrderCommand;
public RelayCommand<OOrderM> SelectedOrderCommand;
}
Where I'm making mistakes? I am not using any library and don't want to so I'm trying to avoid implementing INavigation service. So if not possible this way I will welcome any other suggestions.
Error I'm receiving is
BindingExpression path error: 'SelectedOrderCommand' property not found on 'App.ViewModels.OrdersVM, App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. BindingExpression: Path='SelectedOrderCommand' DataItem='App.ViewModels.OrdersVM, ShopkeeperApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; target element is 'Microsoft.Xaml.Interactions.Core.InvokeCommandAction' (Name='null'); target property is 'Command' (type 'ICommand')