I have a button in my DataGridRowHeader template that I am positioning on the right-hand side of my columns.
The nice thing about this layout is when you click on the button it doesn't select the row, as it would if you located it in a column.
The issue I'm finding now is that I'm trying to bind the row's object properties, for example in the button's ToolTip. It keeps coming back blank, even if I hard-code it in. The same sort of binding on Visibility works fine.
How can I fix the ToolTip?
<DataGrid.RowHeaderTemplate>
<DataTemplate>
<Grid>
<Button x:Name="btnSelectParent"
Template="{StaticResource SelectParentButtonStyle}"
Height="15" Width="15"
Margin="0,0,-669,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
ToolTipService.ShowOnDisabled="True"
Visibility="{Binding DataContext.ShowSelectParentBtn, RelativeSource={RelativeSource AncestorType=DataGridRow}, Converter={StaticResource bool2VisibilityConverter}}" >
<Button.ToolTip>
<TextBlock TextAlignment="Left"
Foreground="Black"
FontWeight="Normal"
Text="{Binding DataContext.ParentBtnMessage, RelativeSource={RelativeSource AncestorType=DataGridRow}}"/>
</Button.ToolTip>
</Button>
</Grid>
</DataTemplate>
</DataGrid.RowHeaderTemplate>
DataGridRowis not a visual ancestor of aButtonin aRowHeaderTemplatebutDataGridRowHeaderis:Your second issue is that the
Tooltipresides in its own element tree. You could solve this by binding theTagproperty of theButtonto theDataContextof theDataGridRowHeaderand then bind to this property using thePlacementTargetof theTooltip: