Picker

Allow users to select objects using pickers

Reference the library

C#
using CI.WSANative.Pickers;

Show a file open picker to choose a single file

Returns an object that wraps the native StorageFile representing the chosen file

You can access the underlying StorageFile by using the result.OriginalFile property but any calls to this must be wrapped in a ENABLE_WINMD_SUPPORT block as it is not editor safe

Use result.ReadBytes() and result.ReadText() to read the files content - calls to these functions should be wrapped in a try catch block

C#
WSANativeFilePicker.PickSingleFile("Select", WSAPickerViewMode.Thumbnail, WSAPickerLocationId.PicturesLibrary, new[] { ".png", ".jpg" }, result => { if (result != null) { byte[] fileBytes = result.ReadBytes(); string fileString = result.ReadText(); } });

Show a file open picker to choose mulitple files

Returns a list of objects that wraps the native StorageFile representing the chosen file

You can access the underlying StorageFile by using the result.OriginalFile property but any calls to this must be wrapped in a ENABLE_WINMD_SUPPORT block as it is not editor safe

Use result.ReadBytes() and result.ReadText() to read the files content - calls to these functions should be wrapped in a try catch block

C#
WSANativeFilePicker.PickMultipleFiles("Select", WSAPickerViewMode.Thumbnail, WSAPickerLocationId.PicturesLibrary, new[] { ".png", ".jpg" }, result => { if (result != null) { foreach (WSAStorageFile file in result) { byte[] fileBytes = file.ReadBytes(); string fileString = file.ReadText(); } } });

Show a file save picker

Returns an object that wraps the native StorageFile representing the chosen file

You can access the underlying StorageFile by using the result.OriginalFile property but any calls to this must be wrapped in a ENABLE_WINMD_SUPPORT block as it is not editor safe

Use result.WriteBytes() and result.WriteText() to write the files content - calls to these functions should be wrapped in a try catch block

C#
WSANativeFilePicker.PickSaveFile("Save", ".jpg", "Test Image", WSAPickerLocationId.DocumentsLibrary, new List<KeyValuePair<string, IList<string>>>() { new KeyValuePair<string, IList<string>>("Image Files", new List<string>() { ".png", ".jpg" }) }, result => { if (result != null) { result.WriteBytes(new byte[2]); result.WriteText("Hello World"); } });

Show a folder picker

Returns an object that wraps the native StorageFolder representing the chosen folder

You can access the underlying StorageFolder by using the result.OriginalFolder property but any calls to this must be wrapped in a ENABLE_WINMD_SUPPORT block as it is not editor safe

The result have various options for accessing files and folders in the selected folder

C#
WSANativeFolderPicker.PickSingleFolder("Ok", WSAPickerViewMode.List, WSAPickerLocationId.DocumentsLibrary, null, result => { if (result != null) { } });

Show a contact picker to choose a single contact

Returns an object that wraps the native Contact representing the chosen contact

You can access the underlying Contact by using the result.OriginalContact property but any calls to this must be wrapped in a ENABLE_WINMD_SUPPORT block as it is not editor safe

C#
WSANativeContactPicker.PickContact(result => { if (result != null) { string fullName = result.FullName; } });

Show a contact picker to choose mulitple contacts

Returns a list of objects that wraps the native Contact representing the chosen contact

You can access the underlying Contact by using the result.OriginalContact property but any calls to this must be wrapped in a ENABLE_WINMD_SUPPORT block as it is not editor safe

C#
WSANativeContactPicker.PickContacts(result => { if (result != null) { foreach (WSAContact contact in result) { string fullName = result.FullName; } } });