WPF Databinding: как мне получить доступ к «родительскому» контексту данных?
У меня есть список (см. Ниже), содержащийся в окне. ОкнаDataContext
имеет два свойства,Items
а такжеAllowItemCommand
.
Как получить привязку дляHyperlink
& APOS; sCommand
свойство должно быть сопоставлено с окномDataContext
?
<ListView ItemsSource="{Binding Items}">
<ListView.View>
<GridView>
<GridViewColumn Header="Action">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<TextBlock>
<!-- this binding is not working -->
<Hyperlink Command="{Binding AllowItemCommand}"
CommandParameter="{Binding .}">
<TextBlock Text="Allow" />
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>