# Data Binding

## Content



The following sections walk you through the steps of binding the Scheduler control to a data source and using the <span data-popup-content="This class is available in both \u003ca href=\u0022/componentone/api/wpf/online-scheduler/dotnet-api/C1.WPF.Schedule/C1.WPF.Schedule.PropertyBridge.html\u0022\u003e.NET\u003c/a\u003e and \u003ca href=\u0022/componentone/api/wpf/online-scheduler/dotnet-api/C1.WPF.Schedule/C1.WPF.Schedule.PropertyBridge.html\u0022\u003e.NET Framework\u003c/a\u003e." data-popup-title="PropertyBridge" data-popup-theme="ui-tooltip-green qtip-green">PropertyBridge</span> class for binding non-dependency properties.

## Bind Scheduler to a Data Source

To bind the Scheduler control to the C1NWind.mdb database, we must configure the data source. Then we can add the dataset as a resource in the project and map to the C1Scheduler Data Storage. To understand these steps in details, see [Configure the Data Source](/componentone/docs/wpf/online-scheduler/WPF_Quick_Start#configure) and [Bind Scheduler to the Data Source](/componentone/docs/wpf/online-scheduler/WPF_Quick_Start#bind) sections in the [Quick Start](/componentone/docs/wpf/online-scheduler/WPF_Quick_Start) topic.

## Data Binding Using the PropertyBridge Class

The PropertyBridge class exposes two dependency properties, **PropertyBridge.Source** and **PropertyBridge.Target**, of the **System.Object** type, and keeps these property values equal. In other words, when the value of one property is changed, the other property is set to the same value. This simple behavior allows you to use non-DependencyProperty properties along with WPF mechanisms that are designed to work with DependencyProperty-only properties. The following examples show how the **PropertyBridge** class can be used:

*   **Binding between two non-dependency properties**:<br />Assign the **PropertyBridge.Source** property with a TwoWay binding having one non-dependency property as a source, and assign the **PropertyBridge.Target** property with a TwoWay binding having another non-dependency property as a source. Then the non-dependency properties will behave as bound properties. This will work well only in classes where exposing these non-dependency properties supports the **INotifyPropertyChanged** interfaces, which is the case for most classes from the <span data-popup-content="This property is available in both \u003ca href=\u0022/componentone/api/wpf/online-scheduler/dotnet-api/C1.WPF.ScheduleCore/C1.WPF.Schedule.C1ScheduleStorage.html\u0022\u003e.NET\u003c/a\u003e and \u003ca href=\u0022/componentone/api/wpf/online-scheduler/dotnet-api/C1.WPF.ScheduleCore/C1.WPF.Schedule.C1ScheduleStorage.html\u0022\u003e.NET Framework\u003c/a\u003e." data-popup-title="C1ScheduleStorage" data-popup-theme="ui-tooltip-green qtip-green">C1ScheduleStorage</span> object model.
*   **Setting a non-dependency property value from with a Trigger**:<br />Assign the **PropertyBridge.Source** property with a **TwoWay** or **OneWayToSource** binding having one non-dependency property as a source, and using Trigger's Setter to set a value to the **PropertyBridge.Target** property of PropertyBridge – this value will be assigned to the non-dependency property which is bound to **PropertyBridge.Source**.
*   **Many-to-many binding**:<br />Assign **PropertyBridge.Source** and **PropertyBridge.Target** with MultiBinding bindings to get many-to-many binding.
*   **Assign a value to a nested property**:<br />Set the target to a **TwoWay** or **OneWayToSource** binding with a Path referencing a nested property. Then, assign **PropertyBridge.Source** (directly or from within a Setter). The nested property will be assigned to this value.
*   **Assign the property of an object that is not accessible directly**:<br />Similar to assigning a value to a nested property, using **RelativeSource** in binding to PropertyBridge.Target, assign a property value for an element that can't be referenced directly in XAML, for example, **TemplatedParent** or some parent element in the visual tree.

The PropertyBridge class is derived from **FrameworkElement** and in order to work properly, it should be placed somewhere in the visual tree among other elements that it should communicate with. The derivation from **FrameworkElement** is intentional; it allows the PropertyBridge to be a part of a visual tree, which in turn provides bindings established on its properties with the correct context. For example, another theoretical option is to have PropertyBridge in the **ResourceDictionary**, but in this case, the bindings would be inoperable.

The **PropertyBridge.Visibility** property is set to **Collapsed** by default, so this object will not appear on a screen and doesn't participate in layout measurement and arrangement processes; it doesn't corrupt a visual representation of the visual tree where it is placed.