views:

1804

answers:

2

I have a list (see below) contained in a window. The window's data context has two properties, Items & 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>
A: 

Can you get into the debugger and step through to the point where the UI is being built?

If so can you get into the variable and try to drill up

PSU_Kardi
+5  A: 

You could try something like this:

...Binding="{Binding RelativeSource={RelativeSource FindAncestor, 
AncestorType={x:Type Window}}, Path=DataContext.AllowItemCommand}" ...
flq
You rock Frank - thanks!
Jordan