I am very new to Xamarin.Form, I would appreciate your help.
I am using MVVM pattern for my current project. I have listview populated with people, I want to select the item in list view and show the detail.
This is my Bindable Class
public static readonly BindableProperty CommandProperty =
BindableProperty.Create(
propertyName: "Command",
returnType: typeof(ICommand),
declaringType: typeof(ListViewItemSelected));
public ICommand Command
{
get { return (ICommand)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
protected override void OnAttachedTo(ListView bindable)
{
base.OnAttachedTo(bindable);
bindable.ItemSelected += BindableOnItemSelected;
bindable.BindingContextChanged += BindableOnBindingContextChanged;
}
private void BindableOnBindingContextChanged(object sender, EventArgs e)
{
var lv = sender as ListView;
BindingContext = lv?.BindingContext;
}
private void BindableOnItemSelected(object sender, SelectedItemChangedEventArgs e)
{
//var lv = sender as ListView;
//var vm = lv?.BindingContext as PersonsListViewModel;
//vm.DetailViewCommand.Execute(null);
if (Command == null)
return;
Command.Execute(null);
}
I am not sure about the next step in my ViewModel.
I created ICommand Property to exacute the method
public ICommand DetailView { get; set; }
In my constructor i added
DetailView = new Command(PathToDetailView);
I created this method
void PathToDetailView()
{
Which I do not know what should go here to redirect to DetailsPage for each item.
}
I am kind of stuck in the DetailViewPage how to get the value.
I appreciate your help.