Click here to Skip to main content
15,890,123 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF decimal validation Pin
arkiboys28-Apr-11 4:15
arkiboys28-Apr-11 4:15 
GeneralRe: WPF decimal validation Pin
Pete O'Hanlon28-Apr-11 5:02
mvePete O'Hanlon28-Apr-11 5:02 
GeneralRe: WPF decimal validation Pin
arkiboys28-Apr-11 18:26
arkiboys28-Apr-11 18:26 
GeneralRe: WPF decimal validation Pin
Mycroft Holmes28-Apr-11 14:16
professionalMycroft Holmes28-Apr-11 14:16 
GeneralRe: WPF decimal validation Pin
Pete O'Hanlon2-May-11 6:29
mvePete O'Hanlon2-May-11 6:29 
QuestionWPF textbox email validation Pin
arkiboys27-Apr-11 22:09
arkiboys27-Apr-11 22:09 
AnswerRe: WPF textbox email validation Pin
Pete O'Hanlon27-Apr-11 22:15
mvePete O'Hanlon27-Apr-11 22:15 
GeneralRe: WPF textbox email validation Pin
arkiboys27-Apr-11 22:46
arkiboys27-Apr-11 22:46 
Thank you for the link...
However, I am trying to use the following method instead which is due to the requirements...
The problem is that I would like to call the IsEmailAllowed when I click away from the Email textbox.
As you see now, the call is in the txtEmail_PreviewTextInput and so, it returns false for each character I enter into the textbox.
Which event of the textbox can I place the code e.Handled = !IsEmailAllowed(e.Text); so it gets called after clicking away from the textbox.

Thanks


private static bool IsEmailAllowed(string text)
        {
            bool blnVallidEmail = false;
            Regex regEMail = new Regex(@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
            if (text.Length > 0)
            {
                if (!regEMail.IsMatch(text))
                {
                    MessageBox.Show("E-Mail expected", "Error", MessageBoxButton.OK, MessageBoxImage.Error);                    
                    blnVallidEmail = !regEMail.IsMatch(text);
                }
            }

            return blnVallidEmail;
        }

        private void txtEmail_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            e.Handled = !IsEmailAllowed(e.Text);                    
        }

GeneralRe: WPF textbox email validation Pin
Wayne Gaylard27-Apr-11 23:46
professionalWayne Gaylard27-Apr-11 23:46 
GeneralRe: WPF textbox email validation Pin
arkiboys28-Apr-11 0:36
arkiboys28-Apr-11 0:36 
GeneralRe: WPF textbox email validation Pin
Pete O'Hanlon27-Apr-11 23:51
mvePete O'Hanlon27-Apr-11 23:51 
GeneralRe: WPF textbox email validation Pin
arkiboys28-Apr-11 0:36
arkiboys28-Apr-11 0:36 
GeneralRe: WPF textbox email validation Pin
Pete O'Hanlon28-Apr-11 0:46
mvePete O'Hanlon28-Apr-11 0:46 
QuestionHow to read data from listbox.Itemtemplate and pass it in xml format Pin
Rocky2327-Apr-11 20:58
Rocky2327-Apr-11 20:58 
AnswerRe: How to read data from listbox.Itemtemplate and pass it in xml format Pin
Abhinav S27-Apr-11 21:33
Abhinav S27-Apr-11 21:33 
GeneralRe: How to read data from listbox.Itemtemplate and pass it in xml format Pin
Rocky2327-Apr-11 21:50
Rocky2327-Apr-11 21:50 
GeneralRe: How to read data from listbox.Itemtemplate and pass it in xml format Pin
Pete O'Hanlon27-Apr-11 21:55
mvePete O'Hanlon27-Apr-11 21:55 
QuestionLine chart API Pin
anishkannan27-Apr-11 20:17
anishkannan27-Apr-11 20:17 
AnswerRe: Line chart API Pin
Abhinav S27-Apr-11 21:31
Abhinav S27-Apr-11 21:31 
AnswerRe: Line chart API Pin
Pete O'Hanlon27-Apr-11 22:07
mvePete O'Hanlon27-Apr-11 22:07 
QuestionAssembly Not Found Error In XAML [modified] Pin
Kevin Marois27-Apr-11 10:51
professionalKevin Marois27-Apr-11 10:51 
AnswerRe: Assembly Not Found Error In XAML Pin
Abhinav S27-Apr-11 18:37
Abhinav S27-Apr-11 18:37 
GeneralRe: Assembly Not Found Error In XAML Pin
Kevin Marois28-Apr-11 7:17
professionalKevin Marois28-Apr-11 7:17 
QuestionWPF namespaces reference [modified] Pin
devvvy26-Apr-11 23:19
devvvy26-Apr-11 23:19 
AnswerRe: WPF namespaces reference Pin
Jammer27-Apr-11 3:42
Jammer27-Apr-11 3:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.