In Windows 8.1, when you add a View/Page based upon a Windows 8.1 Basic Page it no longer inherits from LayoutAware class because it no longer exists in Win 8.1. All Basic Pages now inherit directly from Page class. Additionally, it no longer has an OnNavigatedTo/OnNavigatedFrom event as the Win8.1 Basic page now leverages the NavigationHelper class and calls this.navigationHelper.LoadState and this.navigationHelper.SaveState event handlers. If using the TipCalc sample and adding a Windows Store Basic Page, TipView, initial page would look like:
public sealed partial class TipView : Page
{
private NavigationHelper navigationHelper;
private ObservableDictionary defaultViewModel = new ObservableDictionary();
/// <summary>
/// This can be changed to a strongly typed view model.
/// </summary>
public ObservableDictionary DefaultViewModel
{
get { return this.defaultViewModel; }
}
/// <summary>
/// NavigationHelper is used on each page to aid in navigation and
/// process lifetime management
/// </summary>
public NavigationHelper NavigationHelper
{
get { return this.navigationHelper; }
}
public TipView()
{
this.InitializeComponent();
this.navigationHelper = new NavigationHelper(this);
this.navigationHelper.LoadState += navigationHelper_LoadState;
this.navigationHelper.SaveState += navigationHelper_SaveState;
}
Since the TipView page now inherits directly from Page, if you change the TipView Page to inherit from MvxStorePage like noted below:
public sealed partial class TipView : MvxStorePage
{
private NavigationHelper navigationHelper;
private ObservableDictionary defaultViewModel = new ObservableDictionary();
Since the Page is a partial class the following error occurs:
Partial declarations of 'TipCalc.CrossPlat.WinStore.Views.TipView' must not specify different base classes.
And even if it would allow for the change in the base class to MvxStorePage, you cannot add base.OnNavigatedTo(e) in LoadState event handler as noted:
private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
base.OnNavigatedTo(e);
}
because e parameter in OnNavigatedTo is looking for NavigationEventArgs vs. LoadStateEventArgs.
Any help will be greatly appreciated as I need to complete my cross-platform PCL project which has a Windows 8.1 implementation.
onnavigatedto
still exists – Stuartpublic class TipView: MvxStorePage
but Visual Studio will not compile with the above code and is throwing the following error: Partial declarations of 'TipCalc.CrossPlat.WinStore.Views.TipView' must not specify different base classes. Am I missing another class that I need to change to make this compile? – TaraW