In the many inherited from FrameworkElement in WPF contain a useful dependency property *TemplateSelector type of DataTemplateSelector. It can set our inherit from DataTemplateSelector class and override the method SelectTemplate(). This allow dynamic generate template for a content. Content-data we can get a elementary binding. And now feature: we can use all binding (even that what refet to ElementName), except TemplateBinding, therefore RelativSourceMode doesn't equal TemplatedParent.