MicrosoftDocs / winrt-api

WinRT reference content for developing Microsoft Universal Windows Platform (UWP) apps
Creative Commons Attribution 4.0 International
231 stars 496 forks source link

C++/winrt example? #1034

Closed jevansAN closed 5 years ago

jevansAN commented 5 years ago

Could you show an example of how to provide the filetypechoices in C++/winrt?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

jevansAN commented 5 years ago

OK, in case it's any help let me offer a solution. It took some time. Let's say the file type is txt and we've declared the FileSavePicker. The key is to use Collections:

hstring fileExtension = to_hstring(L".txt"); Windows::Foundation::Collections::IVector extensions{winrt::single_threaded_vector() }; extensions.Append(to_hstring(L".txt")); m_file_save_picker.SuggestedFileName(L"Untitled"); m_file_save_picker.FileTypeChoices().Insert(L"Text file",extensions);

knicholasa commented 5 years ago

Hi @jevansAN, thanks for the feedback and your example. I'm going to update the document to include an example very similar to the one you've shared. Looks like you're on the right track already with your code. The new content should show up next week.