I have a DataGridTemplateColumn with DataTemplate as a PasswordBox.
I want to warn user if CapsLock is toggled.
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
{
if (Keyboard.GetKeyStates(Key.CapsLock) == KeyStates.Toggled)
{
...
Now, I need to raise some PopUp here. I don't know how to do this. Help me please.
I tried to play around with ToolTip like this:
((PasswordBox)sender).SetValue(ToolTipService.InitialShowDelayProperty, 1);
((PasswordBox)sender).ToolTip = "CAPS LOCK";
But it works only when mouse cursor hovers there and I need an independent Popup.
Hit the Windows key & type: Control Panel and then open it. Then steer to the Key Settings tab & double-click on Caps Lock. Now uncheck 'Displays Caps Lock Status on Screen' & reboot your PC.
While all caps can be used as an alternative to rich-text "bolding" for a single word or phrase, to express emphasis, repeated use of all caps can be considered "shouting" or irritating.
a key on a computer keyboard that you press to make any letters you type appear as capital letters until you press it again.
You could show a ToolTip
private void PasswordBox_KeyDown(object sender, KeyEventArgs e)
{
if ((Keyboard.GetKeyStates(Key.CapsLock) & KeyStates.Toggled) == KeyStates.Toggled)
{
if (PasswordBox.ToolTip == null)
{
ToolTip tt = new ToolTip();
tt.Content = "Warning: CapsLock is on";
tt.PlacementTarget = sender as UIElement;
tt.Placement = PlacementMode.Bottom;
PasswordBox.ToolTip = tt;
tt.IsOpen = true;
}
}
else
{
var currentToolTip = PasswordBox.ToolTip as ToolTip;
if (currentToolTip != null)
{
currentToolTip.IsOpen = false;
}
PasswordBox.ToolTip = null;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With