I have a grid of items which is populated using databinding.
In the grid I have a DataTemplate
for certain cells. I need to access the DataContext
of the root element (the one which is hosting the grid) so that I can access additional bindings to support my datatemplate.
So you have:
Window
Window.DataContext = TheDataSourceWithItemsAndSupports
DataGrid.ItemsSource = {Binding Items}
DataTemplate
ListBox.ItemsSource = {Binding Supports}
I want the {Binding Supports}
on TheDataSourceWithItemsAndSupports
, but I don't see how to do that. I tried specifying {Binding}
but that always returns null
. I also tried using RelativeSource FindAncestor
, but that yields null
too.
Any clues?