I have a rich tooltip with a custom control. The custom control contains a scollviewer and I would like this to be scrollable with the mouse wheel, when the tooltip is shown.
The UserControl itself is fine and scrolling works, if shown in a normal view.
<ItemsControl Items="{Binding AllCards}" DockPanel.Dock="Top">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<CardControl ToolTip.Placement="Right"
ToolTip.ShowDelay="10">
<ToolTip.Tip>
<UserControl Content="{Binding Details}" MaxHeight="500"/>
</ToolTip.Tip>
</CardControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Excerpt of the user control shown in the tooltip.
<UserControl>
...
<ScrollViewer MaxHeight="800">
<ItemsControl Items="{Binding HitList}" Margin="0,5,15,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
</UserControl>
It's not possible to scroll ToolTip
content because it cannot receive focus. More appropriate control for this purpose would be a Popup
, it has the same default looks and it will not close when you hover your mouse over.