How do I use CalendarDatePicker::Date() property in UWP C++/WinRT project?

0

I want the user to pick a Date() from the CalendarDatePicker that return Windows::Foundation::IReference. However I call the Windows::Foundation::IReference::GetDateTime() will be able to raise an exception.

Output message:

Exception thrown at 0x00007FFDC893A839 (KernelBase.dll) in BlankApp1.exe: WinRT originate error - 0x80004001 : 'Not implemented'.

Exception thrown at 0x00007FFDC893A839 in BlankApp1.exe: Microsoft C++ exception:winrt::hresult_not_implemented at memory location 0x00000071C2DFCB18.

Exception thrown at 0x00007FFDC893A839 in BlankApp1.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.

BlankApp1.exe has triggered a breakpoint.

The code that raised the exception:

Windows::Foundation::IReference<Windows::Foundation::DateTime> date = MyCalendar().Date();
    if (date != nullptr) {
        auto dt = date.GetDateTime();
    }
    else {
        OutputDebugStringA("You not pick a date.");
    }

The application breakdown in the UnhandledException of App.cpp:

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
}

The value of errorMessage is "Not implemented".

Does anyone has an idea on how to get a Date?

c++
uwp
c++-winrt
asked on Stack Overflow Feb 14, 2020 by Janyee • edited Feb 15, 2020 by Janyee

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0