Long time listener, first time caller. I'm Pretty New to this and I think this is a pretty simple question.
I am building out a Xamarin.Forms application and have a number of static Menus. The question is whether it is best practice to use "OnClick" events in the "CodeBehind" for the Menu or to create a ViewModel and bind them back to navigation commands?
I have kept the code behind empty (barring binding contexts) for everything else and its annoying me that its there for the menus. Is there any benefit either way?
OnClicked: .xaml
<Button Text="Fridge and Freezer" WidthRequest="300" BackgroundColor="DeepSkyBlue" Clicked="onClickedEvent_FridgeFreezer"/>
.cs(In CodeBehind)
async void onClickedEvent_FridgeFreezer(object sender, EventArgs args)
{
await Navigation.PushAsync(new FridgeFreezer());
}
OR
Binding: .xaml
<Button Text="Fridge and Freezer" WidthRequest="300" BackgroundColor="DeepSkyBlue" Command="{Binding GoToFridgeFreezer}"/>
.cs (In a ViewModel)
public ICommand GoToFridgeFreezer{ get; private set; }
async void GoToFridgeFreezer()
{
wait Navigation.PushAsync(new FridgeFreezer());
}