-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
ExceptionValidationRule.xml
117 lines (106 loc) · 8.25 KB
/
ExceptionValidationRule.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<Type Name="ExceptionValidationRule" FullName="System.Windows.Controls.ExceptionValidationRule">
<TypeSignature Language="C#" Value="public sealed class ExceptionValidationRule : System.Windows.Controls.ValidationRule" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ExceptionValidationRule extends System.Windows.Controls.ValidationRule" />
<TypeSignature Language="DocId" Value="T:System.Windows.Controls.ExceptionValidationRule" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ExceptionValidationRule
Inherits ValidationRule" />
<TypeSignature Language="F#" Value="type ExceptionValidationRule = class
 inherit ValidationRule" />
<TypeSignature Language="C++ CLI" Value="public ref class ExceptionValidationRule sealed : System::Windows::Controls::ValidationRule" />
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Windows.Controls.ValidationRule</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Represents a rule that checks for exceptions that are thrown during the update of the binding source property.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The WPF data binding model enables you to associate <xref:System.Windows.Data.Binding.ValidationRules%2A> with a <xref:System.Windows.Data.Binding> object. The <xref:System.Windows.Controls.ExceptionValidationRule> class is a built-in rule that checks for exceptions that are thrown during the updates of the binding source property. You can provide custom logic to specify how the binding engine handles these exceptions by using a <xref:System.Windows.Data.UpdateSourceExceptionFilterCallback>. For more information, see <xref:System.Windows.Data.Binding.UpdateSourceExceptionFilter%2A>.
An alternative syntax to setting the <xref:System.Windows.Controls.ExceptionValidationRule> explicitly is to set the <xref:System.Windows.Data.Binding.ValidatesOnExceptions%2A> property to `true` on your <xref:System.Windows.Data.Binding> or <xref:System.Windows.Data.MultiBinding> object.
You can create a custom rule by creating a class that derives from <xref:System.Windows.Controls.ValidationRule>. For more information and a detailed discussion of data validation, see [Data Binding Overview](/dotnet/framework/wpf/data/data-binding-overview).
## Examples
The <xref:System.Windows.Data.Binding.ValidationRules%2A> property takes a collection of <xref:System.Windows.Controls.ValidationRule> objects. The following example uses <xref:System.Windows.Controls.TextBox.Text%2A?displayProperty=nameWithType> as the binding target property and `StartPrice` (an integer) as the binding source property. When the user enters a value that cannot be converted to an integer, an exception is thrown, which causes the <xref:System.Windows.Controls.ExceptionValidationRule> to invalidate the target value.
:::code language="xaml" source="~/snippets/csharp/System.Windows/DataTemplate/Triggers/AddProductWindow.xaml" id="Snippetdefaultvalidation":::
By default, when there is a validation error, the <xref:System.Windows.Controls.TextBox> appears with a red border. Optionally, you can write a custom <xref:System.Windows.Controls.Validation.ErrorTemplate%2A> to specify how you want to notify the user when there is a validation error.
For more information about data validation, see [Data Binding Overview](/dotnet/framework/wpf/data/data-binding-overview).
For the complete sample, see [Data Binding Demo](https://go.microsoft.com/fwlink/?LinkID=163703).
]]></format>
</remarks>
<altmember cref="T:System.Windows.Controls.ValidationRule" />
<altmember cref="T:System.Windows.Controls.DataErrorValidationRule" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ExceptionValidationRule ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ExceptionValidationRule.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ExceptionValidationRule();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Controls.ExceptionValidationRule" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Validate">
<MemberSignature Language="C#" Value="public override System.Windows.Controls.ValidationResult Validate (object value, System.Globalization.CultureInfo cultureInfo);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance class System.Windows.Controls.ValidationResult Validate(object value, class System.Globalization.CultureInfo cultureInfo) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Controls.ExceptionValidationRule.Validate(System.Object,System.Globalization.CultureInfo)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function Validate (value As Object, cultureInfo As CultureInfo) As ValidationResult" />
<MemberSignature Language="F#" Value="override this.Validate : obj * System.Globalization.CultureInfo -> System.Windows.Controls.ValidationResult" Usage="exceptionValidationRule.Validate (value, cultureInfo)" />
<MemberSignature Language="C++ CLI" Value="public:
 override System::Windows::Controls::ValidationResult ^ Validate(System::Object ^ value, System::Globalization::CultureInfo ^ cultureInfo);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.Controls.ValidationResult</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="value" Type="System.Object" />
<Parameter Name="cultureInfo" Type="System.Globalization.CultureInfo" />
</Parameters>
<Docs>
<param name="value">The value (from the binding target) to check.</param>
<param name="cultureInfo">The culture to use in this rule.</param>
<summary>Performs validation checks on a value.</summary>
<returns>A <see cref="T:System.Windows.Controls.ValidationResult" /> object.</returns>
<remarks>To be added.</remarks>
<altmember cref="M:System.Windows.Controls.ValidationRule.Validate(System.Object,System.Globalization.CultureInfo)" />
</Docs>
</Member>
</Members>
</Type>