Bug 45277

Summary: On UWP, Entry with IsPassword = true does not allow selection of characters
Product: Forms Reporter: John Hardman <jsh001guard-z659>
Component: FormsAssignee: Bugzilla <bugzilla>
Severity: normal CC: FieldstrikeMobile, jas, jsh001guard-z659, paul.dipietro, rui.marinho, v-jawasw
Priority: Normal    
Version: 2.3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Tags: UWP Entry IsPassword ac Is this bug a regression?: ---
Last known good build:

Description John Hardman 2016-10-11 14:59:20 UTC
Using XF, on UWP, an Entry with IsPassword = true does not allow selection of characters.

Typically a keyboard user might do Ctrl+A, Del to quickly delete contents of an Entry, or Ctrl+Home, Ctrl+Shift+End, Del for the same purpose.

Similarly, a mouse user might just swipe the mouse across with the left-button down to do the same thing.

Neither of these work when IsPassword = true.

Easily reproduced, using:

            Entry userPasswordEntry = new Entry
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.StartAndExpand,
                MinimumHeightRequest = 44,
                MinimumWidthRequest = 44
            userPasswordEntry.IsPassword = true;
Comment 1 Paul DiPietro [MSFT] 2017-01-06 16:28:19 UTC
This actually appears to be intended by design.

Comment 2 John Hardman 2017-01-06 16:45:31 UTC
@Paul DiPietro

The comment in the code is as follows:

// This simulates the "do not allow clipboard copy" behavior the PasswordBox control has

Not allowing clipboard copy is different from not being able to select. The implementation may prevent clipboard copy but it inadvertently prevents select. It should not. Being able to select has use cases other than copying to clipboard.
Comment 3 Paul DiPietro [MSFT] 2017-01-11 19:49:23 UTC
John, I spent some time looking this because the assertion you made is correct although a little complicated. I have no guarantees this will be merged but there's a PR which I believe *mostly* fixes this issue:


The behavior as mentioned was presently allowing no selected text, and the current implementation is tricky because of the way that the FormsTextBox works, in that it has a backing Text property and stays synced with the base.Text property. Simply changing the FormsTextBox code so that the selection is allowed isn't an instant fix by itself, as doing something such as entering "123" into the entry, selecting all of it, and then pressing another character like "a" would result in the text being "1". No good. :)

Ultimately what you'll see in that PR is that the SelectionLength is being cached and OnKeyDown is being a bit abused to check against certain key shortcuts like Ctrl-C/X for copy/cut since the regular PasswordBox doesn't allow it. Now, the changes don't fix the fact that the context menu will still enable one to copy the text, but when that's used it only copies the characters as obfuscation characters (the ● character). 

There are also a couple other existing issues that are noted there as well, so I mostly dealt with the matter at hand of selection. The context menu is an issue that might only be fixable on UWP because RT/8.1 doesn't appear to support the use of Clipboard, but I don't think it's the end of the world if it exists as-is for the time being.
Comment 4 Rui Marinho 2017-03-27 17:34:59 UTC
Should be fixed on 2.3.5-pre1
Comment 5 Jacky Waswani 2017-07-14 11:00:20 UTC
Have verified the bug with latest forms build version

Issue is seems to be fixed with latest build as well.

Screen-cast  : https://www.screencast.com/t/mxEg3ji9

Build Info: https://gist.github.com/GLjackyvaswani/600433ce6f3b92544b42d0392001d326
Comment 6 John Hardman 2017-07-14 11:05:23 UTC
Hi Jacky.

I've noticed a few bug reports where a comment starts "Have verified the bug". This wording suggests confirming the bug exists, not that it is fixed. Could you please use different wording on future bug reports (and ask those around you to do the same), either:

"Confirmed bug exists in version n.n.n.x"


"Tested. Bug appears fixed in version n.n.n.x"

(or similar).