textbox - How to show characters for a few seconds in a WPF password box? -


If the user enters the password box in 1985, then four bullets (approx) will be displayed, How can I enter for a few seconds and then turn it into a bullet? I think it can not be done in the password box, but what is the other way to do this?

Enter a text box at the top of the password box, and then use a little dataccess and animation. This part of xaml will appear as long as typing is on the textbox, but as soon as the typing stops, the text box will fade, leaving the password box and leaving the password character.

& lt; window. Resources & gt; & Lt; Storyboard x: key = "storyboard 1" & gt; & Lt; Using Double AnimationFime Storyboard Targetproperty = "(UIElement.Opacity)" storyboard. TargetName = "Textbox" & gt; & Lt; Time of EasingDoubleKeyFrame = "0" value = "1" /> & Lt; EasingDoubleKeyFrame keytime = "0: 0: 0.6" value = "1" /> & Lt; EasingDoubleKeyFrame Keytime = "0: 0: 1.2" value = "0" /> & Lt; / DoubleAnimationUsingKeyFrames & gt; & Lt; / Storyboard & gt; & Lt; /Window.Resources> & Lt; Window.Triggers & gt; & Lt; EventTrigger Routing Avent = "Textbox Box. Text Changed" SourceName = "Text Box" & gt; & Lt; StopStoryboard Start StoryboardName = "Storyboard 1_BeginStoryboard" /> & Lt; StartStoreboard x: Name = "Storyboard 1_Begin Storyboard" Storyboard = "{Static Resources Storyboard 1}" /> & Lt; / EventTrigger & gt; & Lt; /Window.Triggers> & Lt; Password box x: name = "password box" /> & Lt; TextBox x: Name = "text box" Text = "{Binding ElementName = passwordBox, path = password mode = TwoWay, UpdateSourceTrigger = PropertyChanged}" opacity = "100" / & gt;

You can play with the kitimes in animation to get delay while you like.

Edit

If you can change the font setting in the text box to improve the type of text and password characters. You only want to display the last character typed in the form of clear text:

This situation is slightly different and requires some more complexity. This scenario uses only one text box on the window, not the passwordbox

 . & Lt; Name of the text box = "tbxPwd" margin = "20,0" text = "{binding path = demonstratedPwd}" />  

In your code-behind (or your view model class for the window) you two properties, ActualPwd and DisplayedPwd . The text box is bound to the DisplayedPwd property

code-back, you will need the following code:.

  private sub tbxPwd_PreviewKeyDown (as this object, System.Windows.Input.KeyEventArgs manages _ tbxPwd.PreviewKeyDown e) e.Key = Key.Back then ActualPwd .Length & gt; 0 then // final character extract ActualPwd = ActualPwd.Substring (0, ActualPwd.Length - 1) ShowLastCharacter () tbxPwd.CaretIndex = DisplayedPwd.Length end if end if End Sub Private Sub tbxPwd_PreviewTextInput (as this object, e System. Windows.Input.TextCompositionEventArgs) _ Handle TbxPwd.PreviewTextInput ActualPwd & amp; = E.Text e.Handled = True ShowLastCharacter () tbxPwd.CaretIndex = DisplayedPwd.Length End Sub Private Sub Solast character () Reset dim finalized in Char = ActualPwd.Substring (ActualPwd.Length - 1) // display PWD DisplayedPwd = "" For I = Intact ActualPwd.Length as Int32 - 2 DisplayedPwd & amp; = "•" Next DisplayedPwd & amp; = LastChar End Sub of  

tbxPwd_PreviewTextInput method is used to retrieve the character to use typed by the user TbxPwd_PreviewKeyDown method backspace key or back to another control character key That is what you want to know.

There is no delay in this code, so it always clearly displays the last character of the password string. After some delay, to change the last character in the PWD character, it should be easy to add some code with the timer.

The above code is not fully debugged, so if there is a problem

tip: Alt + 0149 displays the 'bullet' password character.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -