Skip to content
This repository was archived by the owner on Aug 27, 2020. It is now read-only.

RelativeBindingContext

Mark Smith edited this page Aug 29, 2016 · 1 revision

RelativeBindingContext

This markup extension allows you to locate an element by name and get it's BindingContext and assign it to another element in the XAML visual tree. The context will be synchronized by default so that if the named element's context changes, the assigned element will be updated.

Properties

  • Name : identifies the XAML element name; must be supplied.
  • TrackBindingChanges : When true (default), keeps the context synchronized between the two elements. Set to false if you only want to get the binding context value and not keep it synchronized at runtime.

Example

In this example, the child ListView will use the page's binding context and not the parent Grid. If the page context changes dynamically, the ListView will be updated at runtime.

<Page x:Name="Root" ...>
   ...
   <Grid BindingContext="...">
       <ListView BindingContext="{inf:RelativeBindingContext Root}" ... />
   </Grid>
</Page>