My scenario:
In the current page I set a DataContext
which consists in two properties, the first (page heading) Question
, the second (a list of items) Replies
.
I'm binding Replies
to the ItemsSource
property of a ListView
:
<ListView x:Name="responseList" ItemsSource="{Binding replies}">
<ListView.ItemTemplate>
<DataTemplate>
<local:CustomControl />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Until this point there are no problems. Inside that Custom Control
, I need to retrieve also some properties of the Question
element (which is outside the ListView
), binding those properties into the XAML of the CustomControl
.
I looked at this but with no luck since FindAncestor
is not recognized in WinRT:
WPF Databinding: How do I access the "parent" data context?
This other one returns nothing as DataContext
: How to access Parent's DataContext in Window 8 store apps
<UserControl ....>
<Grid Background="#33FFFFFF">
<Grid.Resources>
<local:converter1 x:Key="key" Question="{Binding Tag.Question, ElementName=responseList}"/>
</Grid.Resources>
</Grid>
</UserControl>