Access parent object data context

Say if i have a Textbox inside a canvas control and canvas datacontext is set to address object on view model. Now this textbox will by default inherit and correspond to the attributes of this address object in view model. So if this address object has properties like AddressLine1, Street, City etc then i can use any of these to set my textbox text.

But what If i need to go one level up to parent data context and get the name of the main customer object which is bound to the window(or for any matter any parent control) then i can do this:

Binding=”{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.FirstName}

Advertisements