What are the differences between making a binding self-referential via name versus self-referential via RelativeSource?
For example:
<!-- Self referential via name -->
<Window ...
x:Name="This"
DataContext="{Binding Path=Data, ElementName=This}"/>
versus
<!-- Self referential via RelativeSource -->
<Window ...
x:Name="This"
DataContext="{Binding Path=Data, RelativeSource={RelativeSource Self}}"/>
In my project they seem to behave identically, but I'm using them directly in a Window. This means that I immediately prefer the former because it's less typing.
Is the only advantage of RelativeSource its ability to be self-referential in (e.g.) a widely-used style? Or is there some additional semantic difference?
Caveat: Not a WPF wizard
When you are binding directly onto a WPF element as in your example there is no difference. "This" is resolvable and will bind to the same item as Self.
My suspicion is the difference lies when you are binding via constructs such as Style. In that case what you actually want to bind to is the element the style is applied to. In this case RelativeSource Self will give you that element where "this" will just give you a the Style instance.