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
245
How to make PasswordBox
posted

I am Using XamMaskedEditor  and ValueConstraint like this :

 

 

        <igEditors:XamMaskedEditor  

            x:Name="txtUserName" 

            IsEnabled="{Binding Path=IsEditable}"  Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="0"            

            DataContext="{Binding Company}"  EditModeValidationError="txtUserName_EditModeValidationError" 

            >            

            <igEditors:XamMaskedEditor.ValueConstraint>

                <igEditors:ValueConstraint RegexPattern="^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,}$" MinLength="6"/>

            </igEditors:XamMaskedEditor.ValueConstraint>

        </igEditors:XamMaskedEditor>

 

I am having two queries

1.  How to make this textbox as Password textBox as there is no property like PasswordChar="*" as in simple WPF controls.

2. How to change the title of Error messageBox in EditModeValidationError

        private void txtUserName_EditModeValidationError(object sender, Infragistics.Windows.Editors.Events.EditModeValidationErrorEventArgs e)

        {

           e.ErrorMessage= "The password must contain at least one letter and one number ";

        }

 

 

  • 54937
    Suggested Answer
    Offline posted

    mittalamit said:
    1.  How to make this textbox as Password textBox as there is no property like PasswordChar="*" as in simple WPF controls.

    I'm not sure what "simple WPF controls" you are referring to as the only WPF element that I know of which has that property is PasswordBox which doesn't support binding it's Password property. Anyway, currently there is no built in support for displaying a password so you may want to submit a suggestion. It may be possible to provide a custom template for the DisplayCharacterPresenter and put a converter on the textblock that is bound to the DrawString property. In the converter you may be able to evaluate the string and conditionally return a string like "*". Note this would be display only which means the end user could still select the characters and copy them to the clipboard. I've attached a basic sample that does this.

    mittalamit said:
    2. How to change the title of Error messageBox in EditModeValidationError

    There is no parameter for the messagebox. The same title is used for all control instances. The only way to change this would be to use the resource customizer to change the "LMSG_ValueConstraint_InvalidValue" resource. Another option would be to just show your own message box in that event and set the ErrorMessage to null (or an empty string) so the editor doesn't try to show one itself. You may also want to submit a suggestion for adding a property to the event args for the message title.

    TestProject.zip