Reputation: 53
I am trying to add a file selection button to a UWP C++/WinRT application, but I cannot seem to access the constructor following the same namespace as the C# examples here. I have linked the specific Visual Studio error I'm getting below in an image:
If I try to build it despite this error, I get the following output:
1>c:\users\albertdayn\source\repos\siemensirscannersoftware\scanview\mainpage.cpp(39): error C2039: 'FileOpenPicker': is not a member of 'winrt::Windows::Storage::Pickers'
1>c:\program files (x86)\windows kits\10\include\10.0.17763.0\cppwinrt\winrt\impl\windows.storage.pickers.provider.2.h(18): note: see declaration of 'winrt::Windows::Storage::Pickers'
1>c:\users\albertdayn\source\repos\siemensirscannersoftware\scanview\mainpage.cpp(39): error C2065: 'FileOpenPicker': undeclared identifier
Why can't I access the class? If I make a C# application I can run the example given in the link above just fine.
Upvotes: 2
Views: 813
Reputation: 41127
In C# and with C++/CX, references are automatically found and pulled into the modules upon first use.
For C++/WinRT, you need to explicitly include the correct header. In this case:
#include <winrt/Windows.Storage.Pickers.h>
Upvotes: 2