PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 4ms 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//===================================================================================
17using System.Collections.ObjectModel;
18using System.Windows;
19using System.Windows.Controls;
20
21namespace StockTraderRI.Infrastructure
22{
23    /// <summary>
24    /// Defines a <see cref="DependencyProperty"/> where all <see cref="ValidationError"/> are stored to be used from XAML on <see cref="ToolTip"/>.
25    /// </summary>
26    public static class Validation
27    {
28        /// <summary>
29        /// Collection of <see cref="ValidationError"/> ocurred on the attached element.
30        /// </summary>
31        public static readonly DependencyProperty ErrorsProperty = DependencyProperty.RegisterAttached(
32                "Errors", typeof(ObservableCollection<ValidationError>), typeof(Validation), null);
33
34        /// <summary>
35        /// Gets the value of <see cref="ErrorsProperty"/> on <paramref name="dependencyObject"/>.
36        /// </summary>
37        /// <param name="dependencyObject">Element on which the <see cref="ErrorsProperty"/> property is attached.</param>
38        /// <returns>Value of <see cref="ErrorsProperty"/>.</returns>
39        public static ObservableCollection<ValidationError> GetErrors(DependencyObject dependencyObject)
40        {
41            return DependencyPropertyHelper.GetOrAddValue<ObservableCollection<ValidationError>>(dependencyObject, ErrorsProperty);
42        }
43    }
44}