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>
BIG阳
慕村225694
临摹微笑