Methods
public static DualBinding<T> Bind<T>(this IBindable bindable, IndirectBinding<T> controlBinding, DirectBinding<T> valueBinding, DualBindingMode mode = DualBindingMode.TwoWay)
Adds a new binding to the control with a direct value binding
Parameters:
| bindable (IBindable) | Bindable object to add the binding to |
| controlBinding (IndirectBinding<T>) | Binding to get/set the value from the control. |
| valueBinding (DirectBinding<T>) | Value binding to get/set the value from another source. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding |
public static DualBinding<T> Bind<T>(this IBindable bindable, IndirectBinding<T> controlBinding, object objectValue, IndirectBinding<T> objectBinding, DualBindingMode mode = DualBindingMode.TwoWay, T defaultControlValue = default(T), T defaultContextValue = default(T))
Adds a new binding to the control with an indirect binding to the provided
objectValueParameters:
| bindable (IBindable) | Bindable object to add the binding to |
| controlBinding (IndirectBinding<T>) | Binding to get/set the value from the control. |
| objectValue (object) | Object value to bind to. |
| objectBinding (IndirectBinding<T>) | Binding to get/set the value from the objectValue. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
| defaultControlValue (T = null) | Default control value to set to the objectValue, if the value of the control property is null. |
| defaultContextValue (T = null) | Default context value to set to the control, if the objectValue or value of the objectBinding is null. |
public static DualBinding<T> Bind<T>(this IBindable bindable, string propertyName, object source, string sourcePropertyName, DualBindingMode mode = DualBindingMode.TwoWay)
Adds a new dual binding between the control and the specified object
Parameters:
| bindable (IBindable) | Bindable object to add the binding to |
| propertyName (string) | Property on the control to update |
| source (object) | Object to bind to |
| sourcePropertyName (string) | Property on the source object to retrieve/set the value of |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding |
Returns: A new instance of the DualBinding class that is used to control the binding
public static DualBinding<T> Bind<T>(this IBindable bindable, string widgetPropertyName, DirectBinding<T> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
Adds a new dual binding between the control and the specified source binding
Parameters:
| bindable (IBindable) | Bindable object to add the binding to |
| widgetPropertyName (string) | Property on the control to update |
| sourceBinding (DirectBinding<T>) | Binding to get/set the value to from the control |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding |
Returns: A new instance of the DualBinding class that is used to control the binding
public static DualBinding<TValue> Bind<TWidget, TSource, TValue>(this TWidget control, Expression<Func<TWidget, TValue>> controlProperty, TSource source, Expression<Func<TSource, TValue>> sourceProperty, DualBindingMode mode = DualBindingMode.TwoWay)
Binds a control property to a
source propertyParameters:
| control (TWidget) | Control to bind to. |
| controlProperty (Expression<Func<TWidget, TValue>>) | Control property. |
| source (TSource) | Source object to get/set the value from. |
| sourceProperty (Expression<Func<TSource, TValue>>) | Source property from the data context. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
public static DualBinding<TValue> Bind<TWidget, TSource, TValue>(this TWidget control, Expression<Func<TWidget, TValue>> controlProperty, TSource source, IndirectBinding<TValue> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
Binds a control property to the
source object using the sourceBinding.Parameters:
| control (TWidget) | Control to bind to. |
| controlProperty (Expression<Func<TWidget, TValue>>) | Control property expression. |
| source (TSource) | Source object to bind to. |
| sourceBinding (IndirectBinding<TValue>) | Binding to get/set the value from the source. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
public static DualBinding<TValue> Bind<TWidget, TValue>(this TWidget control, Expression<Func<TWidget, TValue>> controlProperty, DirectBinding<TValue> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay)
Bind a control property to the specified
sourceBinding direct binding.Parameters:
| control (TWidget) | Control to bind to. |
| controlProperty (Expression<Func<TWidget, TValue>>) | Control property expression. |
| sourceBinding (DirectBinding<TValue>) | Source binding to get/set the values. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
public static DualBinding<T> BindDataContext<T>(this IBindable bindable, IndirectBinding<T> controlBinding, IndirectBinding<T> dataContextBinding, DualBindingMode mode = DualBindingMode.TwoWay, T defaultControlValue = default(T), T defaultContextValue = default(T))
Adds a new binding from the control to its data context
Parameters:
| bindable (IBindable) | Bindable object to add the binding to |
| controlBinding (IndirectBinding<T>) | Binding to get/set the value from the control. |
| dataContextBinding (IndirectBinding<T>) | Binding to get/set the value from the IBindable.DataContext. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
| defaultControlValue (T = null) | Default control value to set to the objectValue, if the value of the control property is null. |
| defaultContextValue (T = null) | Default context value to set to the control, if the objectValue or value of the objectBinding is null. |
public static DualBinding<T> BindDataContext<T>(this IBindable bindable, string controlPropertyName, string dataContextPropertyName, DualBindingMode mode = DualBindingMode.TwoWay, T defaultControlValue = default(T), T defaultContextValue = default(T))
Adds a new binding with the control and the the control's current data context
Remarks: This binds to a property of the IBindable.DataContext, which will return the topmost value up the control hierarchy. For example, you can set the DataContext of your form or panel, and then bind to properties of that context on any of the child controls such as a text box, etc.
Parameters:
| bindable (IBindable) | Bindable object to add the binding to |
| controlPropertyName (string) | Property on the control to update |
| dataContextPropertyName (string) | Property on the control's IBindable.DataContext to bind to the control |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding |
| defaultControlValue (T = null) | Default value to set to the control when the value from the DataContext is null |
| defaultContextValue (T = null) | Default value to set to the DataContext property when the control value is null |
Returns: A new instance of the DualBinding class that is used to control the binding
public static DualBinding<TValue> BindDataContext<TWidget, TContext, TValue>(this TWidget control, Expression<Func<TWidget, TValue>> controlProperty, Expression<Func<TContext, TValue>> sourceProperty, DualBindingMode mode = DualBindingMode.TwoWay, TValue defaultControlValue = default(TValue), TValue defaultContextValue = default(TValue))
Binds a control property to a BindableWidget.DataContext property
Parameters:
| control (TWidget) | Control to bind to. |
| controlProperty (Expression<Func<TWidget, TValue>>) | Control property. |
| sourceProperty (Expression<Func<TContext, TValue>>) | Source property from the data context. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
| defaultControlValue (TValue = null) | Default control value, if the control value is null. |
| defaultContextValue (TValue = null) | Default context value, if the context value is null. |
public static DualBinding<TValue> BindDataContext<TWidget, TValue>(this TWidget control, Expression<Func<TWidget, TValue>> controlProperty, IndirectBinding<TValue> sourceBinding, DualBindingMode mode = DualBindingMode.TwoWay, TValue defaultControlValue = default(TValue), TValue defaultContextValue = default(TValue))
Binds a control property to a BindableWidget.DataContext property
Parameters:
| control (TWidget) | Control to bind to. |
| controlProperty (Expression<Func<TWidget, TValue>>) | Control property. |
| sourceBinding (IndirectBinding<TValue>) | Source binding to get/set the value on the data context. |
| mode (DualBindingMode = DualBindingMode.TwoWay) | Mode of the binding. |
| defaultControlValue (TValue = null) | Default control value, if the control value is null. |
| defaultContextValue (TValue = null) | Default context value, if the context value is null. |
public static BindableBinding<T, TValue> DefaultIfNull<T, TValue>(this BindableBinding<T, TValue?> binding, TValue? defaultValue = null)
Gets a binding that returns a
defaultValue if the specified binding returns a null value.Parameters:
| binding (BindableBinding<T, TValue?>) | Source of the binding to get the value. |
| defaultValue (TValue? = null) | Default value, or null to use default(TValue). |
Returns: A new binding that returns a non-nullable value.
public static BindableBinding<T, TValue> DefaultIfNull<T, TValue>(this BindableBinding<T, TValue> binding, TValue defaultValue)
Gets a binding that returns a
defaultValue if the specified binding returns a null value.Parameters:
| binding (BindableBinding<T, TValue>) | Source of the binding to get the value. |
| defaultValue (TValue) | Default value to return instead of null. |
Returns: A new binding that returns a non-null value.
Gets a bindable binding with the inverse of the specified boolean value binding.
Parameters:
| binding (BindableBinding<T, bool?>) | Binding to invert. |
Returns: A new binding to the inverse value.
Gets a bindable binding with the inverse of the specified boolean value binding.
Parameters:
| binding (BindableBinding<T, bool>) | Binding to invert. |
Returns: A new binding to the inverse value.
Gets a binding with the inverse of the specified nullable boolean value binding.
Parameters:
| binding (DirectBinding<bool?>) | Binding to invert. |
Returns: A new binding to the inverse value.
Gets a binding with the inverse of the specified nullable boolean value binding.
Parameters:
| binding (DirectBinding<bool>) | Binding to invert. |
Returns: A new binding to the inverse value.
public static IndirectBinding<TValue> ManyToSingle<T, TValue>(this IndirectBinding<IEnumerable<T>> binding, Func<T, TValue> getValue, Action<T, TValue> setValue = null, TValue mixedValue = default(TValue))
Converts a binding of an enumerable of items to a single value by using the provided
getValue function to get the value from each item, and if there are multiple items with different values, returns the specified mixedValue. When setting the value, it will use the provided setValue function to set the value for each item in the enumerable.Parameters:
| binding (IndirectBinding<IEnumerable<T>>) | The binding of the enumerable of items. |
| getValue (Func<T, TValue>) | A function to get the value from each item. |
| setValue (Action<T, TValue> = null) | A function to set the value for each item. |
| mixedValue (TValue = null) | The default value to return if there are multiple different values. |
Returns: A binding that represents a single value extracted from the enumerable.