@@ -83,9 +83,9 @@ private async Task ShowHotkeyRegistrationFailedAsync()
8383 // XamlRoot must be set in the case of a ContentDialog running in a Desktop app
8484 XamlRoot = XamlRoot ,
8585 Style = Application . Current . Resources [ "DefaultContentDialogStyle" ] as Style ,
86- Title = "Invalid hotkey" ,
87- Content = "Failed to register hotkey. Change the hotkey to another key." ,
88- CloseButtonText = "Close" ,
86+ Title = "ContentDialogHotkeyFailedTitle" . GetLocalized ( ) ,
87+ Content = "ContentDialogHotkeyFailedContent" . GetLocalized ( ) ,
88+ CloseButtonText = "ContentDialogHotkeyFailedCloseButtonText" . GetLocalized ( ) ,
8989 DefaultButton = ContentDialogButton . Close
9090 } ;
9191
@@ -94,14 +94,32 @@ private async Task ShowHotkeyRegistrationFailedAsync()
9494
9595 private async Task ApplyHotkeySelectionAsync ( )
9696 {
97- if ( HotkeyManager . RegisterHotkey ( ToggleHotkeyId , ToggleShortcut . Keys ) )
97+ bool registered = HotkeyManager . RegisterHotkey ( ToggleHotkeyId , ToggleShortcut . Keys ) ;
98+ SetShortcutError ( ! registered ) ;
99+
100+ if ( registered )
98101 {
99102 return ;
100103 }
101104
102105 await ShowHotkeyRegistrationFailedAsync ( ) ;
103106 }
104107
108+ /// <summary>
109+ /// Shows or clears the error state on the hotkey's key visuals.
110+ /// </summary>
111+ private void SetShortcutError ( bool isError )
112+ {
113+ // Shortcut doesn't expose an error state, and its key visuals are regenerated whenever its keys change.
114+ ToggleShortcut . UpdateLayout ( ) ;
115+ foreach ( KeyVisual keyVisual in ToggleShortcut . FindDescendants ( ) . OfType < KeyVisual > ( ) )
116+ {
117+ keyVisual . IsError = isError ;
118+ }
119+
120+ ToolTipService . SetToolTip ( ToggleShortcut , isError ? "ContentDialogHotkeyFailedContent" . GetLocalized ( ) : null ) ;
121+ }
122+
105123 /// <summary>
106124 /// Determines whether a control should be enabled based on a checkbox state and a running-state toggle.
107125 /// </summary>
0 commit comments