public class ColumnBinding<T> : IndirectBinding<T>
Column/Index binding for objects implementing IColumnItem or IList
Remarks: This binding is an indirect binding on a particular column/index of each object. This is used to get/set values of a passed-in object to the IndirectBinding<T>.GetValue(object) and IndirectBinding<T>.SetValue(object, T).
T

Constructors

ColumnBinding

#
public ColumnBinding()
Initializes a new instance of the ColumnBinding class

ColumnBinding

#
public ColumnBinding(int column)
Initializes a new instance of the ColumnBinding class with the specified column

Properties

Column

#
public int Column { get; set; }
Gets or sets the column the binding will get/set the value

Methods

AddValueChangedHandler

public virtual object AddValueChangedHandler(object dataItem, EventHandler<EventArgs> handler)
Adds a handler to trap when the value of this binding changes for the specified object
inherited fromIndirectBinding<T>
Remarks: This is used to wire up events (or other mechanisms) to detect if the value is changed for a particular object. This is typically used to fire the DirectBinding<T>.DataValueChanged event (which is wired up automatically)
dataItem (object)object to hook up the value changed event for
handler (EventHandler<EventArgs>)handler for when the value of this binding changes for the specified object
object to track the changed handler (must be passed to IndirectBinding<T>.RemoveValueChangedHandler(object, EventHandler<EventArgs>) to remove)

AfterDelay

public IndirectBinding<T> AfterDelay(double delay, bool reset = false)
Specifies that the binding should only respond to change events after a delay.
inherited fromIndirectBinding<T>
Remarks: This is useful if the property/delegate that is bound is expensive to retrieve the new value, for example to dynamically generate a bitmap based on the state of the model, etc. The reset boolean allows you to ensure that the binding is updated periodically when false (default), or true to wait for the delay period after the last change event.
delay (double)The delay, in seconds to wait after the value has changed before updating the binding.
reset (bool = false)true to reset the delay every time the event is fired, false to trigger the change at least by the delay interval since the last time it was triggered
A binding that will delay the change event

AfterDelay

public IndirectBinding<T> AfterDelay(TimeSpan delay, bool reset = false)
Specifies that the binding should only respond to change events after a delay.
inherited fromIndirectBinding<T>
Remarks: This is useful if the property/delegate that is bound is expensive to retrieve the new value, for example to dynamically generate a bitmap based on the state of the model, etc. The reset boolean allows you to ensure that the binding is updated periodically when false (default), or true to wait for the delay period after the last change event.
delay (TimeSpan)The delay time span to wait after the value has changed before updating the binding.
reset (bool = false)true to reset the delay every time the event is fired, false to trigger the change at least by the delay interval since the last time it was triggered
A binding that will delay the change event

CatchException

public IndirectBinding<T> CatchException(Func<Exception, bool> exceptionHandler = null)
Catches any exceptions when setting the value of the binding
inherited fromIndirectBinding<T>
exceptionHandler (Func<Exception, bool> = null)Handler to call when setting the value, regardless of whether an exception occurs. Return true when the exception is handled, false to throw an exception.
The binding that catches any exception.

CatchException<TException>

public IndirectBinding<T> CatchException<TException>(Func<TException, bool> exceptionHandler = null)
Catches any exceptions of the specified TException when setting the value of the binding.
inherited fromIndirectBinding<T>
exceptionHandler (Func<TException, bool> = null)Handler to call when setting the value, regardless of whether an exception occurs. Return true when the exception is handled, false to throw an exception.
The binding that catches the specified exception.

Child<TNewValue>

public IndirectBinding<TNewValue> Child<TNewValue>(Expression<Func<T, TNewValue>> property)
Binds to the specified child property expression.
inherited fromIndirectBinding<T>
Remarks: This can be used to bind to properties of child objects of your view model, for example
model.SomeProperty.ChildProperty
. This will automatically look up the changed event either by a [Property]Changed event or INotifyPropertyChanged implementation for each object in the heirarchy. Note that you only really need to use this when you have an existing binding that you cannot change. See Binding.Property<T, TValue>(Expression<Func<T, TValue>>) for an example of how to bind to child property values more directly.
property (Expression<Func<T, TNewValue>>)Property to bind to.
The binding to the child property accessed through the current binding.
Use this like so:
public class MyChild { public SomeChildProperty { get; set; } }
public class MyModel { public ChildObject { get; set; } }

Binding.Property((MyModel m) => m.ChildObject).Child(c => c.SomeChildProperty);
// or:
Binding.Property((MyModel m) => m.ChildObject.SomeChildProperty);

Child<TNewValue>

public IndirectBinding<TNewValue> Child<TNewValue>(IndirectBinding<TNewValue> binding)
Binds to the specified child binding of this binding.
inherited fromIndirectBinding<T>
Remarks: This can be used to bind to child objects of your view model, for example
model.SomeProperty.ChildProperty
.
binding (IndirectBinding<TNewValue>)Binding to get the child value from this binding.
The binding to the child property accessed through the current binding.
Use this like so:
public class MyChild { public SomeChildProperty { get; set; } }
public class MyModel { public ChildObject { get; set; } }

Binding.Property((MyModel m) => m.ChildObject).Child(Binding.Property("SomeChildProperty"));

Convert

public IndirectBinding<object> Convert(IValueConverter converter, Type propertyType, object conveterParameter = null, CultureInfo culture = null)
Converts the binding using the specified converter object.
inherited fromIndirectBinding<T>
converter (IValueConverter)Converter object to use when converting to/from the value
propertyType (Type)Type for the converter to convert to
conveterParameter (object = null)Parameter to pass to the converter.
culture (CultureInfo = null)Culture to use for conversion, null to use invariant culture.
A new binding that will be converted using the specified IValueConverter.

Convert<TValue>

public IndirectBinding<TValue> Convert<TValue>(Func<T, TValue> getValue, Action<T, TValue> setValue)
Converts this binding's value to another value using delegates.
inherited fromIndirectBinding<T>
Remarks: This differs from IndirectBinding<T>.Convert<TValue>(Func<T, TValue>, Func<TValue, T>) in that it allows the set value delegate to have access to the original parent value, which can be useful when needing to call a method of the parent binding instead of converting the value directly, or performing other logic.
getValue (Func<T, TValue>)Delegate to get the value from the original binding's type.
setValue (Action<T, TValue>)Delegate to set the value to the original binding's type.
A new binding that will be converted using the specified delegates.

Convert<TValue>

public IndirectBinding<TValue> Convert<TValue>(Func<T, TValue> toValue, Func<TValue, T> fromValue = null)
Converts this binding's value to another value using delegates.
inherited fromIndirectBinding<T>
Remarks: This is useful when you want to cast one binding to another, perform logic when getting/setting a value from a particular binding, or get/set a preoperty of the value.
toValue (Func<T, TValue>)Delegate to convert to the new value type.
fromValue (Func<TValue, T> = null)Delegate to convert from the value to the original binding's type.

Convert<TValue>

public IndirectBinding<TValue> Convert<TValue>(IValueConverter converter, object conveterParameter = null, CultureInfo culture = null)
Converts the binding using the specified converter object.
inherited fromIndirectBinding<T>
converter (IValueConverter)Converter object to use when converting to/from the value
conveterParameter (object = null)Parameter to pass to the converter.
culture (CultureInfo = null)Culture to use for conversion, null to use invariant culture.
A new binding that will be converted using the specified IValueConverter.

EnumToString

public IndirectBinding<string> EnumToString(T defaultValue = default(T))
Converts the a binding to an enumeration to/from its string representation
inherited fromIndirectBinding<T>
defaultValue (T = null)Default if the value is not valid or empty.
Binding to the string value of the enumeration.

GetValue

public T GetValue(object dataItem)
Gets the value from the specified object using this binding
inherited fromIndirectBinding<T>
Remarks: When values are needed from this binding, this method will be called. Implementors of this binding would implement logic in IndirectBinding<T>.InternalGetValue(object)
dataItem (object)object to retrieve the value from
value from the specified object
GetValue

HandleEvent

protected virtual void HandleEvent(string id)
Called to handle an event for this binding
inherited fromBinding

InternalGetValue

#
protected override T InternalGetValue(object dataItem)
Implements the logic to get the value from the specified object

InternalSetValue

#
protected override void InternalSetValue(object dataItem, T value)
Implements the logic to set the value to the specified object
dataItem (object)object to set the value
value (T)value to set at the Column of the specified object

OfType<TValue>

public IndirectBinding<TValue> OfType<TValue>(TValue defaultConvertedValue = default(TValue), T defaultValue = default(T))
Casts this binding value to another (compatible) type, or returns the default if the types do not match.
inherited fromIndirectBinding<T>

RemoveEvent

protected virtual void RemoveEvent(string id)
Called to remove an event for this binding
inherited fromBinding

SetValue

public void SetValue(object dataItem, T value)
Sets the specified value to an object using this binding
inherited fromIndirectBinding<T>
Remarks: This is called to set the value to the object. Implementors of this binding woulc implement logic in IndirectBinding<T>.InternalSetValue(object, T).
dataItem (object)object to set the value to
value (T)value to set to the object
SetValue

ToBool

public IndirectBinding<bool?> ToBool(T trueValue, T falseValue, T nullValue)
Converts this binding to return a nullable boolean binding
inherited fromIndirectBinding<T>
Remarks: This is useful when converting a binding to be used for a checkbox's Checked binding for example. When the binding's value matches the trueValue, it will return true.
trueValue (T)Value when the binding is true.
falseValue (T)Value when the binding is false.
nullValue (T)Value when the binding is null.
Boolean binding.

ToBool

public IndirectBinding<bool?> ToBool(T trueValue, T falseValue)
Converts this binding to return a nullable boolean binding
inherited fromIndirectBinding<T>
Remarks: This is useful when converting a binding to be used for a checkbox's Checked binding for example. When the binding's value matches the trueValue, it will return true.
trueValue (T)Value when the binding is true.
falseValue (T)Value when the binding is false.
Boolean binding.

ToBool

public IndirectBinding<bool?> ToBool(T trueValue)
Converts this binding to return a nullable boolean binding
inherited fromIndirectBinding<T>
Remarks: This is useful when converting a binding to be used for a checkbox's Checked binding for example. When the binding's value matches the trueValue, it will return true.
trueValue (T)Value when the binding is true.
Boolean binding.

ToType<TType>

public IndirectBinding<TType> ToType<TType>(Func<T, TType> invalidGetValue = null, Func<TType, T> invalidSetValue = null)
Uses System.Convert.ChangeType to change the value of the binding to the specified type.
inherited fromIndirectBinding<T>
Remarks: This has additional logic to deal with nullable types so they can be converted properly as well.
invalidGetValue (Func<T, TType> = null)Delegate to get a value when it cannot be converted to the specified TType. When null, an exception will be thrown when the value cannot be converted.
invalidSetValue (Func<TType, T> = null)Delegate to set a value when it cannot be converted from the specified TType. When null, an exception will be thrown when the value cannot be converted.
A binding of the new type that is a converted version of this binding

Unbind

public virtual void Unbind()
Unbind this from the target object(s)
inherited fromBinding
Remarks: Typically a binding may handle an event for when the target object(s) property values are changed. This is called to unbind the binding from the objects so that they can be garbage collected
Unbind

Update

public virtual void Update(BindingUpdateMode mode = BindingUpdateMode.Destination)
Updates the bound target object's value
inherited fromBinding
Remarks: Typically the source would be your custom class and the destination would be a UI control, but this is not always the case.
mode (BindingUpdateMode = BindingUpdateMode.Destination)Direction of the update
Update

Events

Changing

public event EventHandler<BindingChangingEventArgs> Changing
Event to handle when the value is being set using this binding
inherited fromBinding
Remarks: This can be used to stop a value being updated based on custom logic