【发布时间】:2014-10-17 05:02:28
【问题描述】:
我正在 Windows 8 中开发我的第一个应用程序。我在 Windows 8 的第 9 频道看到了教程http://channel9.msdn.com/Series/Windows-Store-apps-for-Absolute-Beginners-with-C-# 我想制作一个演示应用程序,其中数据来自 Web 服务但我无法为我通过 Web 服务接收的 JSON 数据制作 DataSource.cs 文件。
这是我的 JSON 数据来自 Web 服务..
[
{
"id": "1",
"title": "Test_rom",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.1.png"
},
{
"id": "2",
"title": "Jewelry",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.2.png"
},
{
"id": "3",
"title": "Jackets",
"subtitle": "All sizes available",
"icon": "http://lpl.info/Admin/upload/cat.3.png"
},
{
"id": "4",
"title": "Dresses",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.4.png"
},
{
"id": "5",
"title": "Bags",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.5.png"
},
{
"id": "6",
"title": "Watches",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.6.png"
},
{
"id": "8",
"title": "Glasses",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.8.png"
}
]
现在我想为这些组类别 JSON 数据制作一个网格模板。但我是这个领域的新手,我尝试将它与 XAML UI 绑定但我失败了。
我尝试了很多找到一些相关的代码,但所有代码都适用于 windows phone 8,我希望适用于 windows 8 Metro 应用程序。
这些是我感到困惑的 XAML 中的代码。
<Page.Resources>
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="Items"
d:Source="{Binding Groups, Source={d:DesignInstance Type=local:RootObject, CreateList=True}}"/>
</Page.Resources>
与
protected override void LoadState(Object navigationParameter, Dictionary<string,> pageState)
{
OsCatalogData os = new OsCatalogData();
os.GetJson(Constants.OscatalogMenulist, "HomePagemenu");
// TODO: Create an appropriate data model for your problem domain to replace the sample data
this.DefaultViewModel["Group"] = os.?????;
}
我正在尝试从这么多天开始开发它。谁能帮忙?? 我不想要完整的代码但是我可以在哪里满足我的要求的一些材料......
提前谢谢....
【问题讨论】:
标签: c# xaml windows-8 json.net asp.net-web-api