# HG changeset patch # User Steven Hollidge # Date 1335215165 -3600 # Node ID 86ed4919b1262b9c3a8b4db59509cc79c825b12a # Parent 441fdfce70a762b50eee99ea0763bb6e1c513edb Working version! diff -r 441fdfce70a7 -r 86ed4919b126 SilverlightGlimpse/SilverlightGlimpse/Diagnostics/PropertyPathHelper.cs --- a/SilverlightGlimpse/SilverlightGlimpse/Diagnostics/PropertyPathHelper.cs Mon Apr 23 22:05:53 2012 +0100 +++ b/SilverlightGlimpse/SilverlightGlimpse/Diagnostics/PropertyPathHelper.cs Mon Apr 23 22:06:05 2012 +0100 @@ -5,19 +5,26 @@ { public static class PropertyPathHelper { + private static readonly Dummy _dummy = new Dummy(); + public static object GetValue(object source, string propertyPath) { - Binding binding = new Binding(propertyPath) {Mode = BindingMode.OneTime, Source = source}; + var binding = new Binding(propertyPath) + { + Mode = BindingMode.OneTime, + Source = source + }; BindingOperations.SetBinding(_dummy, Dummy.ValueProperty, binding); return _dummy.GetValue(Dummy.ValueProperty); } - private static readonly Dummy _dummy = new Dummy(); - private class Dummy : DependencyObject { public static readonly DependencyProperty ValueProperty = - DependencyProperty.Register("Value", typeof (object), typeof (Dummy), new PropertyMetadata(null)); + DependencyProperty.Register("Value", + typeof (object), + typeof (Dummy), + new PropertyMetadata(null)); } } } diff -r 441fdfce70a7 -r 86ed4919b126 SilverlightGlimpse/SilverlightValidation/Commands/RelayCommand.cs --- a/SilverlightGlimpse/SilverlightValidation/Commands/RelayCommand.cs Mon Apr 23 22:05:53 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Commands/RelayCommand.cs Mon Apr 23 22:06:05 2012 +0100 @@ -5,10 +5,8 @@ { public class RelayCommand : ICommand { - public event EventHandler CanExecuteChanged = delegate { }; - - readonly Action _execute; - readonly Predicate _canExecute; + private readonly Predicate _canExecute; + private readonly Action _execute; public RelayCommand(Action execute, Predicate canExecute = null) @@ -19,11 +17,9 @@ _canExecute = canExecute; } + #region ICommand Members - public void UpdateCanExecuteCommand() - { - CanExecuteChanged(this, new EventArgs()); - } + public event EventHandler CanExecuteChanged = delegate { }; public bool CanExecute(object parameter) @@ -36,5 +32,12 @@ { _execute(parameter); } + + #endregion + + public void UpdateCanExecuteCommand() + { + CanExecuteChanged(this, new EventArgs()); + } } -} +} \ No newline at end of file diff -r 441fdfce70a7 -r 86ed4919b126 SilverlightGlimpse/SilverlightValidation/Data/Factory.cs --- a/SilverlightGlimpse/SilverlightValidation/Data/Factory.cs Mon Apr 23 22:05:53 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Data/Factory.cs Mon Apr 23 22:06:05 2012 +0100 @@ -10,11 +10,11 @@ { return new List(5) { - new UserModel() { Username = "StevenH", Password = "Password1", Email = "steven@hotmail.com", DateOfBirth = new DateTime(1977, 09, 01), Description = ""}, + new UserModel() { Username = "StevenH", Password = "Password1", Email = "steven@hotmail.com", DateOfBirth = new DateTime(1977, 09, 01), Description = "Great binding works"}, new UserModel() { Username = "RichardJ", Password = "12N456a", Email = "dicky@gmail.com", DateOfBirth = new DateTime(1983, 03, 13), Description = "Loves .Net!"}, - new UserModel() { Username = "BobbyP", Password = "pa33Word", Email = "bob@yahoo.co.uk", DateOfBirth = new DateTime(1992, 08, 30), Description = ""}, + new UserModel() { Username = "BobbyP", Password = "pa33Word", Email = "bob@yahoo.co.uk", DateOfBirth = new DateTime(1992, 08, 30), Description = "Adores fruit"}, new UserModel() { Username = "DavidM", Password = "poIu789", Email = "daveyboy@marsh.com", DateOfBirth = new DateTime(1965, 06, 21), Description = "Java fan boy"}, - new UserModel() { Username = "JessieJ", Password = "jlkJh567", Email = "jj@apple.co.uk", DateOfBirth = new DateTime(1990, 10, 15), Description = ""} + new UserModel() { Username = "JessieJ", Password = "jlkJh567", Email = "jj@apple.co.uk", DateOfBirth = new DateTime(1990, 10, 15), Description = "StackOverflow deity"} }; } } diff -r 441fdfce70a7 -r 86ed4919b126 SilverlightGlimpse/SilverlightValidation/Views/UserListView.xaml --- a/SilverlightGlimpse/SilverlightValidation/Views/UserListView.xaml Mon Apr 23 22:05:53 2012 +0100 +++ b/SilverlightGlimpse/SilverlightValidation/Views/UserListView.xaml Mon Apr 23 22:06:05 2012 +0100 @@ -23,10 +23,21 @@ +