WPF Databinding: How do I access the “parent” data context?

I have a list (see below) contained in a window. The window’s DataContext has two properties, Items and AllowItemCommand.

How do I get the binding for the Hyperlink‘s Command property needs to resolve against the window’s 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>

3 Answers
3

Leave a Comment