CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.9k stars 1.37k forks source link

TextBoxExtensions Mask #4334

Closed archergod closed 3 years ago

archergod commented 3 years ago

I am trying to use TextBox Mask Extension as per sample (https://docs.microsoft.com/en-us/windows/communitytoolkit/extensions/textboxmask) I put my mask as "99-99-99", but when UWP app runs, it shows me field as "--__", which is fine (and expected).

But now to data enter in this field, user has to select the "" and then type its numeric character, i.e. he select individual underscore ( ) and then type value. which is not expected as obviously it slows data entry. Is there any problem in Mask or is there any setting I am missing. ( I try to use Mask Placeholder) but it doesn't help in this case.

ghost commented 3 years ago

Hello archergod, thank you for your interest in Windows Community Toolkit!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible.. Other community members may also answer the question and provide feedback 🙌

michael-hawker commented 3 years ago

@archergod not sure if I follow the issue here and what you mean by 'selecting an underscore'.

Can you edit the sample in our sample app, provide the XAML you used, and explain more about what the current behavior you're seeing is and how it differs from your expectations?

archergod commented 3 years ago

Hello, The Sample apps works fine for me. To explain it better.. When we have Mask set, say "99-99-99" is my mask, so when I focus on field it shows "--_" (as I didn't change placeholder mask character. so Ideally when you type any number from keyboard it should replace with that number.

But in my UWP app it doesn't do that, I have to select the "" and then type one character. Then I have to select second mask and type next character.

Not sure why this behaviour happens in app, it doesn't happen in sample apps.

my Textbox is define as

<TextBox x:Name="BankSortCode" MinWidth="300" MaxWidth="320" MaxLength="8" Header="Bank Sort Code" Padding="5" Margin="5,10,5,0" Text="{x:Bind ViewModel.SelectedSupplier.BankSortCode, Mode=TwoWay}" ui:TextBoxExtensions.Mask="99-99-99" RelativePanel.Below="Currency" RelativePanel.AlignLeftWithPanel="True" />

It is inside a expandar control. and I am using latest version of CommunityToolkit. sorry I cannnot share app itself and even I cannot reproduce it on sample app.

XAML-Knight commented 3 years ago

The problem is your MaxLength property - try increasing it, or removing it altogether.

archergod commented 3 years ago

Perfect, Removing MaxLength works like charm. Thanks. I think it should be mention in Documentation too.