Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
134
how to implement auto fill 0 in xamMaskedEditor?
posted

for example,mask="{char:5:0-9}".when user just input "123" and lost focus,I want to progam can auto fill 0 in front of "123",like this "00123". 

how to implement this requirement in xamMaskedEditor??thanks!

  • 2070
    posted

     Hi Daniel,

     

    One way you can do this is to hook into EditModeEnded and modify the value of the editor at that point:

    public void maskedEditor_EditModeEnded( object sender, RoutedEventArgs e )
    {
        string text = this.maskedEditor.Text;
        if ( ! string.IsNullOrEmpty( text ) && text.Length < 5 )
            text = new string( '0', 5 - text.Length ) + text;

        this.maskedEditor.Text = text;
    }

     

    Hope this helps,

    Sandip