积极答复者
win8 metro开发求助“ C++ 创建你的第一个 Metro 风格应用” 编译错误

问题
-
在微软提供的 win8 metro开发例子中 "使用C++构建你的第一个metro风格应用",地址是:http://technet.microsoft.com/zh-cn/library/hh465045
第一部分,博客预览器,我按你们提示的步骤和代码,制作好了。
第二部分,在添加了“项目页”,“扯分页”,“基本页”之后,在 app.xaml.cpp 中添加
void InitDataSource(Platform::Collections::Vector<FeedData^>^ fds); FeedData^ GetFeedData(Windows::Web::Syndication::SyndicationFeed^ feed);
方法实现时,会编译出错“
error C2893: 未能使函数模板“'unknown-type' Concurrency::details::_VoidReturnTypeHelper(_Function,int,...)”专用化 (App.xaml.cpp)
”
求助,我是按你们提供的步骤和代码做的。
请问你有这个例子的,可以编译通过的源代码吗?
答案
-
OK,我看了这个文档下面的讨论描述 英文版有讨论:http://msdn.microsoft.com/en-us/library/windows/apps/hh465045.aspx, Michael Blome 给出了RP的修改方法:在app.xaml.cpp中的GetFeedData 实现中最后一个.then([this](task<<SyndicationFeed^> t) 修改成
.then( [] (concurrency::task<void> t)
因为此文档的内容是基于CP版本做的,现在RP有所小变化, 我按照文档做了一个例子,你看下是否有什么遗漏的和错误了。
https://skydrive.live.com/#cid=51B2FDD068799D15&id=51B2FDD068799D15%211065
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已编辑 Jie BaoModerator 2012年8月2日 4:37
- 已标记为答案 Jie BaoModerator 2012年8月3日 10:55
-
我这测试的环境已经是RTM了,所以又有了一些小变化:
1. BindableBase 需要继承自 DependencyObject
BindableBase.h
public ref class BindableBase : Windows::UI::Xaml::DependencyObject, Windows::UI::Xaml::Data::INotifyPropertyChanged { public:
2. DateConverter的方法重载需要匹配参数名:
virtual Platform::Object^ Convert(Platform::Object^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object^ parameter,
Platform::String^ culture)改成
virtual Platform::Object^ Convert(Platform::Object^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object^ parameter,
Platform::String^ language)ConvertBack类似
3. FeedItem,FeedData 去掉析构方法
RTM版本测试:https://skydrive.live.com/#cid=51B2FDD068799D15&id=51B2FDD068799D15%211065
如何打开第三个页面, 在SplitPage上右侧部分右击,打开上方的AppBar 点击ViewDetail 即可导航进入第三个页面。
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jie BaoModerator 2012年8月27日 3:54
全部回复
-
创建你的第一个地铁风格的应用程序使用的C + +
http://msdn.microsoft.com/en-us/library/windows/apps/hh465045.aspx
- 已合并 Jie BaoModerator 2012年8月2日 2:46 duplicate
-
先在头文件中添加函数声明
-
将此
#include
指令添加到 app.xaml.h:#include "FeedData.h"
-
将这两个专用方法签名添加到 app.xaml.h 中的 App 类:
void InitDataSource(Platform::Collections::Vector<FeedData^>^ fds); FeedData^ GetFeedData(Windows::Web::Syndication::SyndicationFeed^ feed);
然后在cpp中先include和引入相应的头文件以及名字空间:
#include <ppltasks.h> #include "ItemsPage.xaml.h" using namespace Platform::Collections; using namespace Windows::Web::Syndication; using namespace concurrency; using namespace std;
然后添加方法实现。
你是这么操作的吗?
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
-
-
OK,我看了这个文档下面的讨论描述 英文版有讨论:http://msdn.microsoft.com/en-us/library/windows/apps/hh465045.aspx, Michael Blome 给出了RP的修改方法:在app.xaml.cpp中的GetFeedData 实现中最后一个.then([this](task<<SyndicationFeed^> t) 修改成
.then( [] (concurrency::task<void> t)
因为此文档的内容是基于CP版本做的,现在RP有所小变化, 我按照文档做了一个例子,你看下是否有什么遗漏的和错误了。
https://skydrive.live.com/#cid=51B2FDD068799D15&id=51B2FDD068799D15%211065
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已编辑 Jie BaoModerator 2012年8月2日 4:37
- 已标记为答案 Jie BaoModerator 2012年8月3日 10:55
-
我这测试的环境已经是RTM了,所以又有了一些小变化:
1. BindableBase 需要继承自 DependencyObject
BindableBase.h
public ref class BindableBase : Windows::UI::Xaml::DependencyObject, Windows::UI::Xaml::Data::INotifyPropertyChanged { public:
2. DateConverter的方法重载需要匹配参数名:
virtual Platform::Object^ Convert(Platform::Object^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object^ parameter,
Platform::String^ culture)改成
virtual Platform::Object^ Convert(Platform::Object^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object^ parameter,
Platform::String^ language)ConvertBack类似
3. FeedItem,FeedData 去掉析构方法
RTM版本测试:https://skydrive.live.com/#cid=51B2FDD068799D15&id=51B2FDD068799D15%211065
如何打开第三个页面, 在SplitPage上右侧部分右击,打开上方的AppBar 点击ViewDetail 即可导航进入第三个页面。
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jie BaoModerator 2012年8月27日 3:54