WPF already defines Binding and TemplateBinding. Is there a way to define my own custom binding type.
For example, could I declare a "SelfBinding" where RelativeSource == RelativeSource.Self?
WPF already defines Binding and TemplateBinding. Is there a way to define my own custom binding type.
For example, could I declare a "SelfBinding" where RelativeSource == RelativeSource.Self?
Yes, Binding and TemplateBinding are known as markup extensions and you can create your own. Also see here for implementation details.
Edit:You can just inherit from binding making it very simple.
public class SelfBinding : Binding
{
public SelfBinding(string path) : base(path)
{
RelativeSource = new RelativeSource(RelativeSourceMode.Self);
}
}