I'm trying to do binding like this
<local:TempUserControl>
<local:TempUserControl.Foo>
<local:Foo Name2="{Binding Path=Name, RelativeSource={RelativeSource AncestorType={x:Type local:TempUserControl}}}"/>
</local:TempUserControl.Foo>
</local:TempUserControl>
and getting error
Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='WpfApplication1.TempUserControl', AncestorLevel='1''. BindingExpression:Path=Name; DataItem=null; target element is 'Foo' (Name=''); target property is 'Name2' (type 'String')
Any idea please what is wrong?
Foo
is a custom dependency property inTempUserControl
? How doesTempUserControl
use this property? – Pieter WitvoetFoo
object isn't a logical child of thatTempUserControl
- it's just a property. – Pieter Witvoet