wpf relativesource code behind code example
Example: wpf binding ancestor codebehind
Binding b = new Binding();
b.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor,this.GetType(),1);
b.Path = new PropertyPath("MyDP");
MyLable.SetBinding(ContentProperty, b);