Creates a data binding from a DependencyObject's DependencyProperty to a CLR property on an Object.
Regular Bindings only support DependencyObject DependencyProperties as their targets, and a given DependencyObject instance's property may only be the Target of a single binding at a time. Although Bindings support BindingMode.OneWayToSource, the single Target restriction means that we cannot use a OneWayToSource binding as the final link in a data binding chain.
ReverseBinding makes it possible to use a CLR property as a binding target by listening to value change events on the source DependencyObject's DependencyProperty and setting the resulting value on the CLR Object Property. Note that unlike WPF BindingExpressions, a ReverseBinding object uses full references to its source and target. This implies that clients must be more careful about managing the object lifecycle.
A ReverseBinding will only establish the data binding after its properties have all been set and EstablishBinding is called.
Public Member Functions |
|
ReverseBinding () | |
void | Dispose () |
Break this binding and release references.
|
|
void | EstablishBinding () |
Establish the data binding, setting the
current source value in the target object, and subscribing to value
change events in order to update the target value as the source
changes. |
|
void | BreakBinding () |
Remove the binding between the source and
the target. |
|
void | ResolveTargetByUid () |
Look up and set the Target Ribbon element
identified by TargetUid. |
|
Static Public Member Functions |
|
static ReverseBinding | CreateReverseBinding (DependencyObject source, String sourceProperty, Object target, String targetProperty) |
Convenience method for completely setting up
a
ReverseBinding, setting all properties and calling
EstablishBinding. |
|
static ReverseBinding | CreateReverseBinding (DependencyObject source, String sourceProperty, Object target, String targetProperty, IValueConverter converter) |
Convenience method for completely setting up
a
ReverseBinding, setting all properties and calling
EstablishBinding. |
|
Protected Member Functions |
|
virtual void | Dispose (bool disposing) |
Break this binding and release references.
|
|
Properties |
|
DependencyObject |
Source [get, set] |
Source of the data binding. |
|
String |
SourceProperty [get, set] |
Name of the source property on the source
object of the data binding. |
|
Object |
Target [get, set] |
Target of the data binding. |
|
String |
TargetUid [get, set] |
Unique identifier for Ribbon element binding
targets. |
|
String |
TargetProperty [get, set] |
Target property on the target object.
|
|
IValueConverter |
Converter [get, set] |
Value converter applied between the Source
value and the Target value. |
|
Guid |
Key [get, set] |
Resource Key value, saved after
deserializing a XAML file. |
WPFCustomControls::ReverseBinding::ReverseBinding | ( | ) | [inline] |
static ReverseBinding WPFCustomControls::ReverseBinding::CreateReverseBinding | ( | DependencyObject | source, |
String | sourceProperty, | ||
Object | target, | ||
String | targetProperty | ||
) | [inline, static] |
Convenience method for completely setting up a ReverseBinding, setting all properties and calling EstablishBinding.
source | Source object in the data binding. |
sourceProperty | Name of the source property in the data binding. This must be a DependencyProperty. |
target | Target object receiving the bound data. |
targetProperty | Name of the target property receiving the bound data. |
static ReverseBinding WPFCustomControls::ReverseBinding::CreateReverseBinding | ( | DependencyObject | source, |
String | sourceProperty, | ||
Object | target, | ||
String | targetProperty, | ||
IValueConverter | converter | ||
) | [inline, static] |
Convenience method for completely setting up a ReverseBinding, setting all properties and calling EstablishBinding.
source | Source object in the data binding. |
sourceProperty | Name of the source property in the data binding. This must be a DependencyProperty. |
target | Target object receiving the bound data. |
targetProperty | Name of the target property receiving the bound data. |
converter | Converter used to modify the source value before applying it to the target. |
void WPFCustomControls::ReverseBinding::Dispose | ( | ) | [inline] |
Break this binding and release references.
void WPFCustomControls::ReverseBinding::EstablishBinding | ( | ) | [inline] |
Establish the data binding, setting the current source value in the target object, and subscribing to value change events in order to update the target value as the source changes.
void WPFCustomControls::ReverseBinding::BreakBinding | ( | ) | [inline] |
Remove the binding between the source and the target.
This binding will no longer respond to value changes on the source property.
void WPFCustomControls::ReverseBinding::ResolveTargetByUid | ( | ) | [inline] |
Look up and set the Target Ribbon element identified by TargetUid.
virtual void WPFCustomControls::ReverseBinding::Dispose | ( | bool | disposing | ) | [inline, protected, virtual] |
Break this binding and release references.
disposing | This is an explicit call to Dispose() |
DependencyObject
WPFCustomControls::ReverseBinding::Source [get,
set] |
Source of the data binding.
String
WPFCustomControls::ReverseBinding::SourceProperty [get,
set] |
Name of the source property on the source object of the data binding.
Must be a DependencyProperty.
Object
WPFCustomControls::ReverseBinding::Target [get,
set] |
Target of the data binding.
This object will receive the source's current value when the binding is established and will be updated when the source value changes.
String
WPFCustomControls::ReverseBinding::TargetUid [get,
set] |
Unique identifier for Ribbon element binding targets.
TargetUid serves primarily to support serialization of ReverseBindings. When constructing a ReverseBinding for a Ribbon element Target, the TargetUid may be used to identify the target element instead of setting the target object instance directly. When the binding is established, the ReverseBinding searches the Ribbon for its child element identified by this Uid.
String
WPFCustomControls::ReverseBinding::TargetProperty [get,
set] |
Target property on the target object.
IValueConverter
WPFCustomControls::ReverseBinding::Converter [get,
set] |
Value converter applied between the Source value and the Target value.
Guid WPFCustomControls::ReverseBinding::Key
[get, set] |
Resource Key value, saved after deserializing a XAML file.
Preserving the Key allows us to spit out a XAML as unchanged when serialized, then deserialized, and then serialized again.