PageRenderTime 35ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/V2/trunk/RI/Silverlight/StockTraderRI.Infrastructure.Silverlight/Validation.cs

#
C# | 44 lines | 15 code | 2 blank | 27 comment | 0 complexity | 4ff84f382666cc62b380edf8c28c5837 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System.Collections.ObjectModel;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. namespace StockTraderRI.Infrastructure
  21. {
  22. /// <summary>
  23. /// Defines a <see cref="DependencyProperty"/> where all <see cref="ValidationError"/> are stored to be used from XAML on <see cref="ToolTip"/>.
  24. /// </summary>
  25. public static class Validation
  26. {
  27. /// <summary>
  28. /// Collection of <see cref="ValidationError"/> ocurred on the attached element.
  29. /// </summary>
  30. public static readonly DependencyProperty ErrorsProperty = DependencyProperty.RegisterAttached(
  31. "Errors", typeof(ObservableCollection<ValidationError>), typeof(Validation), null);
  32. /// <summary>
  33. /// Gets the value of <see cref="ErrorsProperty"/> on <paramref name="dependencyObject"/>.
  34. /// </summary>
  35. /// <param name="dependencyObject">Element on which the <see cref="ErrorsProperty"/> property is attached.</param>
  36. /// <returns>Value of <see cref="ErrorsProperty"/>.</returns>
  37. public static ObservableCollection<ValidationError> GetErrors(DependencyObject dependencyObject)
  38. {
  39. return DependencyPropertyHelper.GetOrAddValue<ObservableCollection<ValidationError>>(dependencyObject, ErrorsProperty);
  40. }
  41. }
  42. }