TemplateBinding and TemplateParent Digging

9 בMay 2016

One of the things that can completely freak you out. Lets start with facts: 1.  While customize an application you might use something like this: <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MyProperty}"/> Or maybe this: <TextBlock Text="{TemplateBinding MyProperty}" /> While this is on the ResourceDictionary of your app and about to styling your custom control, and MyProperty is an DependencyProperty on the logic part of the Control so what the different between those two?  And what the default choose should be? By the way while most of programmers used to write You can use the Short way as: Text="{Binding TemplatedParent.MyProperty2}" 2.    A full demonstration will be like  this one: public class CustomControl1 : Control ...
אין תגובות