Binding to a Dependency Property is easy in code-behind. You just create a new System.Windows.Data.Binding
object, and then call the target dependency object\'s
You can bind a CLR property to a DepenencyProperty on a control, for example. In this cae, the CLR property is the SOURCE of the binding and the DependencyProperty is the TARGET of the binding. For it to work, the class with the CLR property has to implement INotifyPropertyChanged.
Here's how you do it in the code behind:
Binding canModifyBinding = new Binding();
canModifyBinding.Source = LastRecord;
canModifyBinding.Path = new PropertyPath( "CanModify" );
BindingOperations.SetBinding( this, CanModifyProperty, canModifyBinding );
In this case, the Binding object represents the information about the Source: What object is the source, which property of that object is the one you're interested in. BindingOperations.SetBinding is a static method which specifies which DependencyProperty on which DependencyObject is the target of the binding (arguments 2 & 1, respectively), and the Binding to use to get at the source.
HTH
Tony