在Windows 8.1中,当您添加基于Windows 8.1 Basic Page的View/Page时,它不再继承LayoutAware类,因为它在Win 8.1中不再存在.现在,所有基本页面都直接从Page类继承.此外,它不再具有OnNavigatedTo/OnNavigatedFrom事件,因为Win8.1 Basic页面现在利用NavigationHelper类并调用this.navigationHelper.LoadState和this.navigationHelper.SaveState事件处理程序.如果使用TipCalc示例并添加Windows Store基本页面,TipView,初始页面将如下所示:
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; }
} …Run Code Online (Sandbox Code Playgroud)