Structuring content on a tablet and on a desktop computer is very similar in many ways. On phones, however, we are much more limited in what we can do. Therefore, in this section, we will create a specific view for this app when it's used on phones. To do so, perform the following steps:
- Create a new XAML-based Content Page in the Views folder.
- Call the new view MainView_Phone.
- Use Resolver in the constructor of the view to set BindingContext to MainViewModel, as shown in the following code:
public MainView_Phone ()
{
InitializeComponent ();
BindingContext = Resolver.Resolve<MainViewModel>();
}
To trigger the LoadData method in MainViewModel, call the LoadData method by overriding the OnAppearing method on the main thread. To do this, perform the following steps:
- In the Weather project, open the MainView_Phone.xaml.cs file.
- Add the override of the OnAppearing method, as shown in the following code:
protected...