I am confused with whn to use {RelativeSource Self} when binding. The below three bindings look the same to me, where MyText is a property in my view model.
<TextBlock Text = "{Binding Path=MyText RelativeSource{RelativeSource Self} }" />
<TextBlock Text = "{Binding MyText RelativeSource{RelativeSource Self} }" />
<TextBlock Text = "{Binding MyText }" />
When should I use Self in my binding? Thanks.
The first two are equivalent, and bind to the
MyTextproperty of theTextBlockitself. But of course, they don't work, because there is noMyTextproperty onTextBlock.The third binds to the
MyTextproperty of the currentDataContextUse
RelativeSource.Selfwhen you need to bind to a property of the current control.