I even created a demo app to demonstrate. We're setting some tooltips on a field in the CellValuePresenter using a Template.
After rebinding the grid (setting the DataSource to a new list) the tooltips go into a strange, non-deterministic state.
Even in this simple example you can see the tooltips for the Description field get mixed up in the right grid after clicking on a few rows in the left grid. (try it a few times and you'll see it)
This is a pretty critical issue for us. Need help as soon as possible.
Hello Steve,
Thank you for your response. I believe that other community members may benefit from it.
For future generations:
Development's response:
It is the result of some quirkiness in the farmework's Tooltip element not picking up the new DataContext when recycling elements. The fix is very easy. Just add a Binding for the Tooltip's DataConext to its PlacementTarget's DataContext e.g.:
<TextBlock.ToolTip>
<ToolTip DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}"
Visibility="{Binding Path=DataItem.Description, Converter={StaticResource TooltipVisibilityConverter}}">
<TextBlock Text="{Binding Path=DataItem.Description}"></TextBlock>
</ToolTip>
</TextBlock.ToolTip>
The visibility issue isn't the source of the problem. We actually have a visibility converter in our real application, not having one is just a side effect of me trying to hand over a quick demo app.
As you can see, I updated the demo to include the visibility converter and the tooltip problem still exists.
Hello,
I have investigated this issue using your demo app and I was able to reproduce the behavior you have described. When I hovered over the description field, FormatException is thrown in the output. After removing the tooltip visibility I was not able to reproduce this issue anymore and the text in the tooltip was the same as the text in the cell. It seems that the reason for this behavior is that you try to bind the Visibility property of the tooltip which is of type Visibility to the DataItem.Description which is of type string. I could suggest you bind the Visibility to source that is of the same type, use converter or does not use the Visibility at all if you do not need it.
Please feel free to let me know if you have any other questions or concerns on the matter.