Now that we have rebuilt our MainPage
, let's make some small changes to the MainPageViewModel
. Since we replaced the label bindings with static values, we remove the following variables, DescriptionMessage
, ExitTitle
, and LocationTitle
.
Now we should have the following private
properties:
#region Private Properties private readonly IMethods _methods; private ICommand _stocklistCommand; private ICommand _exitCommand; #endregion
Now simply update LocationCommand
to the following:
public ICommand StocklistCommand { get { return stocklistCommand; } set { if (value.Equals(stocklistCommand)) { return; } _stocklistCommand = value; OnPropertyChanged("StocklistCommand"); } }
We must also update our constructor:
#region Constructors public MainPageViewModel (INavigationService navigation, Func<Action, ICommand> commandFactory, IMethods methods) : base (navigation) { this.exitCommand = commandFactory (() => methods.Exit()); this.stocklistCommand = commandFactory (async () => await this.Navigation.Navigate(PageNames.StocklistPage, null)); } #endregion
Here we simply rename some variables to match our application. We must also copy over the Enums
and Extras
folder, and replace the LocationPage
enum to StocklistPage
.
Next, we need to add the PortableModule
. Create a new folder called Modules
and copy the PortableModule
from Location.Portable
. Change the PortableModule
class to the following:
public class PortableModule : IModule { public void Register(ContainerBuilder builer) { builer.RegisterType<MainPageViewModel> ().SingleInstance(); builer.RegisterType<StocklistPageViewModel> ().SingleInstance(); } }
Finally, we need to add INavigationService
. Create a new folder called UI
and add INavigationService
from Location.Portable
into the new UI
folder.
Before we move any further we must update the namespaces in the code sheets copied from the Locator
project. The easiest way is by using Search | Replace in Files.... We want to replace the text Location.Portable
with the text.
3.142.174.55