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.
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.
UPDATE
Sadly the link is gone and I have not found the referenced article anymore.
As far as I remember, the referenced blog has shown how to bind to a DataContext of another VisualTree, which is often necessay when binding from a ToolTip, a ContextMenu or a Popup.
A nice way to do this, is to provide the desired instance (e.g. ViewModel) within the Tag-property of the PlacementTarget. The following example does this for accessing a Command-instance of a ViewModel:
I have not tested it and its a long time I did this the last time. Please make a comment if it does not work for you.
UPDATE 2
As the original link that this answer was written about is gone, I hit archive.org and found the original blog entry. Here it is, verbatim from the blog: