59
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
1 using System.Windows;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
2 using System.Windows.Browser;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
3 using System.Windows.Controls;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
4 using System.Windows.Data;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
5 using System.Windows.Input;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
6 using SilverlightValidation.ViewModels;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
7 using SilverlightValidation.Models;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
8 using SilverlightValidation.Validators;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
9
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
10 namespace SilverlightValidation.Views
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
11 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
12 public partial class UserView
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
13 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
14 private UserViewModel vm;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
15 public UserView()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
16 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
17 InitializeComponent();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
18 HtmlPage.Document.SetProperty("title", "Silverlight Validation");
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
19
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
20 vm = new UserViewModel(UserModel.Create(), new UserModelValidator());
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
21 this.DataContext = vm;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
22 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
23
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
24 private static void UpdateTextBoxSource(object sender)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
25 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
26 BindingExpression be = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
27 be.UpdateSource();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
28 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
29
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
30 private void DatePicker_KeyDown(object sender, KeyEventArgs e)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
31 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
32 if (e.Key != Key.Tab)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
33 e.Handled = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
34 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
35
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
36 private void tbUsername_LostFocus(object sender, RoutedEventArgs e)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
37 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
38 UpdateTextBoxSource(sender);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
39 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
40
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
41 private void tbPassword_LostFocus(object sender, RoutedEventArgs e)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
42 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
43 BindingExpression be = ((PasswordBox)sender).GetBindingExpression(PasswordBox.PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
44 be.UpdateSource();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
45 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
46
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
47 private void tbEmail_LostFocus(object sender, RoutedEventArgs e)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
48 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
49 UpdateTextBoxSource(sender);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
50 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
51
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
52 private void dpDateOfBirth_LostFocus(object sender, RoutedEventArgs e)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
53 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
54 BindingExpression be = ((DatePicker)sender).GetBindingExpression(DatePicker.SelectedDateProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
55 be.UpdateSource();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
56 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
57 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
58 } |