Does It works with PasswordBox controls?

Feb 19, 2009 at 10:27 AM
Hi guys, this tool is very powerful, but I don't understand if it works with PasswordBox controls also.
My XAML code is like this:
                   
<!-- password control -->
                    <PasswordBox  x:Name="" Width="90" Height="25" Grid.Row="2" Grid.Column="2" VerticalAlignment="Top" >
                        <slv:ValidatorService.Validator>
                            <slv:LengthValidator ManagerName="ValidateGroup"  IsRequired="True" MinLength="3" ErrorMessage="Campo obbigatorio, minimo 3 caratteri"/>
                        </slv:ValidatorService.Validator>
                    </PasswordBox>


My goal should be having 3 characters length and the a field requiring, but something doesn't work...
(I'm sorry for my english but I write from Italy.)
bye
Feb 19, 2009 at 10:51 AM
Hi, I downloaded the code and modified LengthValidator.cs :

        protected override bool ValidateControl()
        {
            // Check TextBox
            if (ElementToValidate is TextBox)
            {
                TextBox box = ElementToValidate as TextBox;
                return box.Text.Length >= MinLength && box.Text.Length <= MaxLength;
            }
            // Check PasswordBox
            if (ElementToValidate is PasswordBox)
            {
                PasswordBox box = ElementToValidate as PasswordBox;
                return box.Password.Length >= MinLength && box.Password.Length <= MaxLength;
            }
            return true;
        }
Now works fine!

Thank you