c++ - 如何在 UWP C++/WinRT 项目中使用 CalendarDatePicker::Date() 属性?
问题描述
我希望用户从返回 Windows::Foundation::IReference 的 CalendarDatePicker 中选择一个Date() 。但是我调用Windows::Foundation::IReference::GetDateTime()将能够引发异常。
输出消息:
在 BlankApp1.exe 中的 0x00007FFDC893A839 (KernelBase.dll) 处引发异常:WinRT 发起错误 - 0x80004001:“未实现”。
在 BlankApp1.exe 中的 0x00007FFDC893A839 处引发异常:Microsoft C++ 异常:winrt::hresult_not_implemented 在内存位置 0x00000071C2DFCB18。
在 BlankApp1.exe 中的 0x00007FFDC893A839 处引发异常:Microsoft C++ 异常:[rethrow] 在内存位置 0x0000000000000000。
BlankApp1.exe 已触发断点。
引发异常的代码:
Windows::Foundation::IReference<Windows::Foundation::DateTime> date = MyCalendar().Date();
if (date != nullptr) {
auto dt = date.GetDateTime();
}
else {
OutputDebugStringA("You not pick a date.");
}
App.cpp的UnhandledException中的应用分解:
App::App() {
InitializeComponent();
Suspending({ this, &App::OnSuspending });
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e) {
if (IsDebuggerPresent()) {
auto errorMessage = e.Message();
__debugbreak();
}
});
#endif
}
errorMessage 的值为“未实现”。
有人知道如何获取日期吗?
解决方案
推荐阅读
- python - Matplotlib:添加多个箭头以产生结果箭头
- docker - 当一个容器旋转另一个容器时,docker 在容器之间共享数据
- f# - 使用 F# ExcelProvider 处理多行标题和隐藏列
- php - count():参数必须是第8行实现Countable的数组或对象
- javascript - Ajax 与 Node.js/Express 404
- spring-boot - 未调用 Spring Batch 跳过策略
- python - matplotlib 中使用颜色图的条形图
- reactjs - 盖茨比:独特的“关键”道具
- python - 没有这样的文件或目录:使用绝对路径时
- android - 如何在颤动中获取小部件的坐标、比例和旋转数据?