Click here to Skip to main content
15,905,679 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF decimal validation Pin
Ian Shlasko28-Apr-11 3:10
Ian Shlasko28-Apr-11 3:10 
AnswerRe: WPF decimal validation Pin
Pete O'Hanlon28-Apr-11 3:47
mvePete O'Hanlon28-Apr-11 3:47 
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 
In a textbox for the wpf application, how can I make sure the user enters a valid email address please?

I am using regular expressoion as follows but clicking away from the textbox still seems to be ok even if there is no proper email address in the textbox.
And I am not sure if regular expression is the right thing for this purpose.

Thanks
My existing code:

private static bool IsEmailAllowed(string text)
        {
            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]$");
            return !regEMail.IsMatch(text);
        }

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


This is what I used to do in windows but there is nothing similar to it in wpf

private void txtEmail_Validating(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.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 (txtEmail.Text.Length > 0)
            {
                if (!rEMail.IsMatch(txtEmail.Text))
                {
                    MessageBox.Show("E-Mail expected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtEmail.SelectAll();
                    e.Cancel = true;
                }
            }
        }

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 
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 

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.