Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

TextBoxMask Extension Binding Text Issue #3335

Closed

Description

@rizamarhaban

Describe the bug

Applying TextBoxMask on TextBox control is working. However, when the binding value changes, the TextBox UI did not reflect the changes.

  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:

Steps to Reproduce

Steps to reproduce the behavior (I'm using PRISM 6.x):

  1. Add these XAML,
<TextBox
	Width="120"
	Padding="0,4,0,0"
	VerticalAlignment="Center"
	extensions:TextBoxMask.CustomMask="5:[0-5]"
	extensions:TextBoxMask.Mask="99:59:59"
	extensions:TextBoxMask.PlaceHolder="--:--:--"
	Header="Opening Time"
	Text="{x:Bind ViewModel.OpeningTime, Mode=TwoWay}"
	TextAlignment="Center" />
<TextBox
	Width="120"
	Padding="0,4,0,0"
	VerticalAlignment="Center"
	extensions:TextBoxMask.CustomMask="5:[0-5]"
	extensions:TextBoxMask.Mask="99:59:59"
	extensions:TextBoxMask.PlaceHolder="--:--:--"
	Header="Closing Time"
	Text="{x:Bind ViewModel.ClosingTime, Mode=TwoWay}"
	TextAlignment="Center" />
  1. Add the property binding in ViewModel,
private string _openingTime =  "00:00:00";
private string _closingTime = "23:59:59"; 
private ICommand _resetToDefaultCommand;

public string OpeningTime
{
    get { return _openingTime; }
    set { SetProperty(ref _openingTime, value); }
}

public string ClosingTime
{
    get { return _closingTime; }
    set { SetProperty(ref _closingTime, value); }
}

public ICommand ResetToDefaultCommand => _resetToDefaultCommand ??
    (_resetToDefaultCommand = new DelegateCommand(() =>
{
        OpeningTime = "00:00:00";
        ClosingTime = "23:59:59";
    }));

When Reset Button clicked, the TextBox did not update the UI. However, if we delete one digit at the back or delete any digit, the value updated.

Expected behavior

When ResetToDefault Button clicked:
OpeningTime should be showing: 00:00:00
ClosingTime should be showing: 23:59:59

Screenshots

scenario
As we can see here, if the value entered following the mask correctly, and then we update the value via binding, the TextBox did not properly reflect the changes. However, if one of the digit is missing, the value is updated perfectly.

Environment

NuGet Package(s):

Package Version(s):

Windows 10 Build Number:

  • Version 1909 (18363.778)

App min and target version:

  • Version 1909 (18363.778)

Device form factor:

  • Desktop

Visual Studio

  • 2019 Preview (version: 16.7.0 Preview 2.0)

Additional context

Add any other context about the problem here.

Activity

  1. added
    bug 🐛An unexpected issue that highlights incorrect behavior
    on Jun 8, 2020
  2. Kyaa-dost commented on Jun 8, 2020

    @Kyaa-dost
    Contributor

    @rizamarhaban Thanks for highlighting the bug. Is this something you can work on, create a PR ?

  3. added
    help wantedIssues identified as good community contribution opportunities
    and removed on Jun 8, 2020
  4. rizamarhaban commented on Jun 8, 2020

    @rizamarhaban
    ContributorAuthor

    Okay, will check the code first.

  5. rizamarhaban commented on Jun 9, 2020

    @rizamarhaban
    ContributorAuthor

    @Kyaa-dost I found the code. It seems the correct TextBox.Text was overridden by the oldtext. The binding works normally but was overridden. Will try to fix this and create PR later.

    image

  6. rizamarhaban commented on Jun 9, 2020

    @rizamarhaban
    ContributorAuthor

    @Kyaa-dost I have fixed the code however I cannot push my branch or create the PR. Need help on this.

  7. removed
    help wantedIssues identified as good community contribution opportunities
    on Jun 9, 2020
  8. michael-hawker commented on Jun 9, 2020

    @michael-hawker
    Member

    @rizamarhaban sounds like you just cloned the main repo. If you create a fork in GitHub:

    image

    You should be able to change your remote to your new fork, then you can push your feature branch to your fork, and then submit a PR to our main repo here with the fix!

    Let us know if you need more help submitting the PR! Thanks!

  9. rizamarhaban commented on Jun 10, 2020

    @rizamarhaban
    ContributorAuthor

    @michael-hawker I'm getting this failed test when running the unit tests. Is this something that I should leave it? it seems has no relation with my simple changes. Other tests passed.

    image

  10. michael-hawker commented on Jun 10, 2020

    @michael-hawker
    Member

    @rizamarhaban looks like the tests passed in the CI, but adding @Sergio0694 here for help with understanding why they might fail locally.

  11. added this to the 7.0 milestone on Jun 10, 2020
  12. Sergio0694 commented on Jun 10, 2020

    @Sergio0694
    Member

    Mmmh those crashes are very weird, also I'm pretty sure those FileNotFound are due to some referenced package not being loaded correctly. @michael-hawker have some NuGet packages been updated in the 7.0 branch? I see the CI is running all tests just fine in master 🤔

  13. rizamarhaban commented on Jun 11, 2020

    @rizamarhaban
    ContributorAuthor

    @Sergio0694 @michael-hawker maybe this detail will help to resolve this,

    image

    My laptop has 32GB memory,

    image

  14. michael-hawker commented on Jun 25, 2020

    @michael-hawker
    Member

    @rizamarhaban thanks, we've found the issue and it will be resolved by #3365. So, don't worry about those tests failing locally, you should be all good, thanks!

    I also was able to repro similar issues with just XAML directly here in the sample app:

                    <TextBox Grid.Row="3"
                    x:Name="TestText"
                             Text="10:20:30"
                             Header="Source" 
                             Style="{StaticResource MaskedTextBoxStyle}"/>
    
                    <TextBox Grid.Row="4"
                             extensions:TextBoxMask.CustomMask="5:[0-5]"
                             extensions:TextBoxMask.Mask="99:59:59"
                             Header="Target"
                             Text="{Binding Text, ElementName=TestText, Mode=TwoWay}"
                             Style="{StaticResource MaskedTextBoxStyle}" />

    Taking a look at your PR suggested fix now, thanks!

  15. Sergio0694 commented on Jun 25, 2020

    @Sergio0694
    Member

    @michael-hawker Actually the second issue, the OutOfMemoryException from that HighPerformance test, has already been solved (that was in #3350), so if that has been merged into this PR I think it should already be fixed in here as well 👍

  16. ghost closed this as completedin #3338on Oct 6, 2020
  17. ghost added a commit that references this issue on Oct 6, 2020
    31bf71f
  18. ghost locked as resolved and limited conversation to collaborators on Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Completed 🔥bug 🐛An unexpected issue that highlights incorrect behavior

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions