Click or drag to resize

BindableExtensionsBindDataContextT Method (IBindable, String, String, DualBindingMode, T, T)

Adds a new binding with the control and the the control's current data context

Namespace:  Eto.Forms
Assembly:  Eto (in Eto.dll) Version: 2.5.3-dev
Syntax
public static DualBinding<T> BindDataContext<T>(
	this IBindable bindable,
	string controlPropertyName,
	string dataContextPropertyName,
	DualBindingMode mode = DualBindingMode.TwoWay,
	T defaultControlValue = null,
	T defaultContextValue = null
)

Parameters

bindable
Type: Eto.FormsIBindable
Bindable object to add the binding to
controlPropertyName
Type: SystemString
Property on the control to update
dataContextPropertyName
Type: SystemString
Property on the control's DataContext to bind to the control
mode (Optional)
Type: Eto.FormsDualBindingMode
Mode of the binding
defaultControlValue (Optional)
Type: T
Default value to set to the control when the value from the DataContext is null
defaultContextValue (Optional)
Type: T
Default value to set to the DataContext property when the control value is null

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:Eto.Forms.BindableExtensions.BindDataContext``1(Eto.Forms.IBindable,System.String,System.String,Eto.Forms.DualBindingMode,``0,``0)"]

Return Value

Type: DualBindingT
A new instance of the DualBinding class that is used to control the binding

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IBindable. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
This binds to a property of the 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.
See Also