views:

22

answers:

2

What am I doing wrong here?:

 <GridViewColumn>
    <GridViewColumn.CellTemplate>
       <DataTemplate>
          <Button>
            <Button.ToolTip>
              <TextBlock Text="{Binding Path=Title, RelativeSource={RelativeSource AncestorType=Window}}" />

That's just a simplified example, that doesn't work anyway :) Actually I need to get a value from another property that is in scope of the Window's DataContext.

Help me pls.

+2  A: 

This is tricky because ToolTip is not part of the VisualTree. Here you see a cool solution for the same problem with ContextMenus. The same way you can go for the ToolTip.

HCL
This is it! Thank you!
Ike
A: 

I think it should be done like this:

{Binding Path=Title, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
mdm20
Nope... doesn't work. I've tried that one already...
Ike
@mdm20: This works not because the main VisualTree is not available from the ToolTip. See my answer.
HCL
yah sorry, didn't actually even notice that it was within a tooltip.
mdm20