E
E
Evgeny Semashko2021-01-06 18:15:59
WPF
Evgeny Semashko, 2021-01-06 18:15:59

How to validate PasswordBox in WPF?

I want to set validation for PasswordBox, but it doesn't work like I did for TextBoxes

Example
<TextBox x:Name="email"
                     materialDesign:HintAssist.Hint="Email"
                     Style="{StaticResource MaterialDesignFloatingHintTextBox}"
                     Width="140"
                         Margin="0,0,0,-2">
                    <TextBox.Text>
                        <Binding Path="Email" UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <rules:IsEmail ValidatesOnTargetUpdated="False"/>
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>

And this example works great.
How can I do something similar for PasswordBox? As still it would be desirable to receive value of PasswordBox'a to it in a DB.
I don't use MVVM pattern

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LiptonOlolo, 2021-01-07
@evgenysemashko

It is better to look towards MVVM and INotifyPropertyChanged, IDataErrorInfo interfaces.
Ps: Life will make it easier to use ValidationContext.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question