3
WPF数据绑定:如何访问“父”数据上下文?
我在窗口中包含一个列表(见下文)。窗口DataContext具有两个属性,Items和AllowItemCommand。 如何获得对绑定Hyperlink的Command属性需要解析对窗口的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>