BindingGroup Property

FrameworkElement.BindingGroup Property


Gets or sets the BindingGroup that is used for the element.

Namespace:   System.Windows
Assembly:  PresentationFramework (in PresentationFramework.dll)

public BindingGroup BindingGroup { get; set; }

Property Value

Type: System.Windows.Data.BindingGroup

The BindingGroup that is used for the element.

A BindingGroup can be used to validate the values of multiple properties of an object. For example, suppose that an application prompts the user to enter an address and then populates an object of type Address, which has the properties Street, City, ZipCode, and Country, with the values that the user provided. The application has a panel that contains four TextBox controls, each of which is bound to one of the object’s properties. You can use a ValidationRule in a BindingGroup to validate the Address object. For example, the ValidationRule can ensure that the zip code is valid for the country of the address.

Child elements inherit the BindingGroup from their parent elements, just as with any other inheritable property.

Identifier field


Metadata properties set to true


The following examples are part of an application that checks whether the user has set the properties of two objects to equal values. The first example creates two TextBox controls, each of which is bound to a different data source. The StackPanel has a BindingGroup that contains a ValidationRule that checks that the two strings are equal.

The following example shows the ValidationRule that the previous example uses. In the Validate method override, the example gets each source object from the BindingGroup and checks whether the properties of the objects are equal.

To invoke the ValidationRule, call the UpdateSources method. The following example calls UpdateSources when the click event of the button occurs.

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft