This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextBox TextChanging="TextBox_OnTextChanging" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void TextBox_OnTextChanging(TextBox sender, TextBoxTextChangingEventArgs args) | |
{ | |
sender.Text = new String(sender.Text.Where(char.IsDigit).ToArray()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var library = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<StorageLibrary> TryAccessLibraryAsync(KnownLibraryId library) | |
{ | |
try | |
{ | |
return await StorageLibrary.GetLibraryAsync(library); | |
} | |
catch (UnauthorizedAccessException) | |
{ | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//explain the issue | |
MessageDialog requestPermissionDialog = | |
new MessageDialog($"The app needs to access the {library}. " + | |
"Press OK to open system settings and give this app permission. " + | |
"If the app closes, reopen it afterwards. " + | |
"If you Cancel, the app will have limited functionality only."); | |
//setup dialog commands | |
var okCommand = new UICommand("OK"); | |
requestPermissionDialog.Commands.Add(okCommand); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (requestPermissionResult == cancelCommand) | |
{ | |
//user chose to Cancel, app will not have permission | |
return null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//open app settings to allow users to give us permission | |
await Launcher.LaunchUriAsync(new Uri("ms-settings:appsfeatures-app")); | |
//confirmation dialog to retry | |
var confirmationDialog = new MessageDialog($"Please give this app the {library} permission " + | |
"in the Settings app which has now opened."); | |
confirmationDialog.Commands.Add(okCommand); | |
await confirmationDialog.ShowAsync(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<StorageLibrary> TryAccessLibraryAsync(KnownLibraryId library) | |
{ | |
try | |
{ | |
return await StorageLibrary.GetLibraryAsync(library); | |
} | |
catch (UnauthorizedAccessException) | |
{ | |
//explain the issue | |
MessageDialog requestPermissionDialog = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userManager = (UserManager)GetSystemService(UserService); | |
if (userManager.IsUserAGoat) | |
{ | |
//🐐 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ActivityManager.IsUserAMonkey) | |
{ | |
//🐒🐵🙊🙉🙈 | |
} |