Skip to content

TextBoxMask Extension Binding Text Issue #3335

@rizamarhaban

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.

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