Using SL4, I have a DataGrid defined as follow (simplified)
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate x:Key="MyDataTemplate">
<Grid>
<TextBlock Text="{Binding SomeField}">
<ToolTipService.ToolTip>
<ToolTips:ToolTip>
<TextBlock Text="{Binding MyToolTipField}" />
</ToolTip>
</ToolTipService.ToolTip>
</TextBlock>
</Grid>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<sdk:DataGrid ItemsSource="{Binding MySource}">
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn
SortMemberPath="MySortField"
CanUserSort="True"
CellTemplate="{StaticResource MyDataTemplate}" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
Now, I have a DataContext set on the user control to my ViewModel class defined like so (again, simplified)
public class MyDataContext
{
public ObservableCollection<MyItem> MySource {get; set;}
}
public class MyItem
{
public string SomeField {get;set;}
public string MySortField {get;set;}
public string MyToolTipField {get;set;}
}
As it is now, the tooltip displays the correct data when the grid first appeared. The tooltip also displays fine when the grid is sorted by clicking the grid header.
However, when the tooltip is displayed AND the grid is updated from the view model then the tooltip displays the wrong data (it's from another row).
If the grid is not sorted then the tooltip updated perfectly when the view model updates the data.
Since a tooltip does not have a datacontext set since it is not a child of the control in question it would seem that setting its datacontext should do the trick. Alas it does not help.
Interestingly, if the tooltip is defined as
<TextBlock Text="{Binding SomeField}"
ToolTipService.ToolTip="{Binding MyToolTipField}" />
it works fine even if the grid is sorted.
Keep in mind that I'm after the problem when the tooltip is still displayed (on a sorted grid) when the binding data is updated in the view model.