【发布时间】:2012-06-02 05:20:04
【问题描述】:
我正在尝试使用 Windows 8 社区预览版在 MSVS 11 Beta 上完成这个 Metro“Hello World”:
Create Your First Metro Style App using C# or VB
本教程要求您创建一些“模板”页面。例如:
public sealed partial class SplitPage : WindowsBlogReader.Common.LayoutAwarePage
{
...
本教程还要求您覆盖其中一些页面的 LoadState() 方法:
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
// TODO: Assign a bindable group to this.DefaultViewModel["Group"]
// TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"]
FeedData feedData = navigationParameter as FeedData;
if (feedData != null)
{
this.DefaultViewModel["Feed"] = feedData;
this.DefaultViewModel["Items"] = feedData.Items;
}
...
问题在于,这会因严重的编译错误而死:
LoadState(object,System.Collections.Generic.Dictionary<string,object>): no suitable method found to override.
模板(SplitPage.xaml.cs)的自动生成代码中没有“页面状态管理”区域,也没有默认的“LoadState()”方法;教程说应该有。
问:LoadState() 现在在 Metro SDK 的新版本中被弃用了吗?
问:我需要在 .xaml 文件中做一些“魔术”来完成这项工作吗?
问:这到底是怎么回事?
非常感谢您,如果有人有任何建议! 教程还要求您覆盖其中一些页面的 LoadState() 方法:
【问题讨论】:
-
你的基类
LayoutAwarePage包含LoadState,所以protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)可以工作。然而,我在这里偶然发现,因为我的LoadState(...)没有执行。 ://
标签: c# microsoft-metro winrt-xaml