Control.DataContext Property

Definition

Gets or sets the data context for the purpose of data binding. This is an ambient property.

C#
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.Browsable(false)]
public virtual object? DataContext { get; set; }

Property Value

Attributes

Remarks

Data context is a concept that allows elements to inherit information from their parent elements about the data source that is used for binding. It's the duty of deriving controls which inherit from this class to handle the provided data source accordingly. For example, UserControls, which use BindingSource components for data binding scenarios could either handle the DataContextChanged event or override OnDataContextChanged(EventArgs) to provide the relevant data from the data context to a BindingSource component's DataSource.

Applies to

Product Versions
Windows Desktop 7, 8, 9