1 public sealed partial class SettingsPageControl : UserControl
ShortcutWithTextLabelControl Attributes
Name
Class
Text
ShortcutWithTextLabelControl
Keys
ShortcutWithTextLabelControl
Example 1 2 3 4 5 6 7 <StackPanel > <dev:ShortcutWithTextLabelControl x:Name ="HotkeyMicVidControl" Text ="to toggle both your microphone and video" /> <dev:ShortcutWithTextLabelControl x:Name ="HotkeyMicControl" Text ="to toggle your microphone" /> <dev:ShortcutWithTextLabelControl x:Name ="HotkeyVidControl" Text ="to toggle your microphone" /> <Button Content ="Open Shortcut Dialog" Click ="Button_Click" /> </StackPanel >
1 2 3 HotkeyMicVidControl.Keys = new List<object > { "Ctrl" , "Alt" , "F5" }; HotkeyMicControl.Keys = new List<object > { "Ctrl" , "Alt" , "F5" }; HotkeyVidControl.Keys = new List<object > { "Ctrl" , "Alt" , "F5" };
ShortcutDialogContentControl Attributes
Name
Class
Keys
ShortcutDialogContentControl
IsError
ShortcutDialogContentControl
IsWarningAltGr
ShortcutDialogContentControl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 private ShortcutDialogContentControl c = new ShortcutDialogContentControl();private ContentDialog shortcutDialog;bool canClose = false ;public void OpenDialog (){ c.Keys = new List<object > { "Ctrl" , "Alt" , "F5" }; shortcutDialog = new ContentDialog { XamlRoot = Content.XamlRoot, Title = "Activation shortcut" , Content = c, PrimaryButtonText = "Save" , SecondaryButtonText = "Confirm" , CloseButtonText = "Cancel" , DefaultButton = ContentDialogButton.Primary, }; shortcutDialog.Closing += ShortcutDialog_Closing; shortcutDialog.PrimaryButtonClick += ShortcutDialog_PrimaryButtonClick; shortcutDialog.SecondaryButtonClick += ShortcutDialog_SecondaryButtonClick; shortcutDialog.CloseButtonClick += ShortcutDialog_CloseButtonClick; await shortcutDialog.ShowAsyncQueue(); } private void ShortcutDialog_CloseButtonClick (ContentDialog sender, ContentDialogButtonClickEventArgs args ){ canClose = true ; } private void ShortcutDialog_Closing (ContentDialog sender, ContentDialogClosingEventArgs args ){ args.Cancel = !canClose; } private void ShortcutDialog_PrimaryButtonClick (ContentDialog sender, ContentDialogButtonClickEventArgs args ){ DisableKeys(); } private void ShortcutDialog_SecondaryButtonClick (ContentDialog sender, ContentDialogButtonClickEventArgs args ){ EnableKeys(); } private void EnableKeys (){ shortcutDialog.IsPrimaryButtonEnabled = true ; c.IsError = false ; } private void DisableKeys (){ shortcutDialog.IsPrimaryButtonEnabled = false ; c.IsError = true ; }
Demo you can run demo and see this feature.