I have programmed an application that draws elements in a canvas as described in this other post
I did it following the instructions of @grek40 and it works well.
Now I would like to add a tooltip to the elements drawn in the Canvas (only Tasks elements which are represented by a Border class). This is my code:
<DataTemplate DataType="{x:Type local:TaskItem}">
<Border
Background="#0074D9"
BorderBrush="#001F3F"
BorderThickness="2"
Width="{Binding Width}"
Height="{Binding Height}">
<TextBlock
Text="{Binding Id}"
FontSize="20"
Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Border.ToolTip>
<ToolTip Background="#D5F0F0FF">
<StackPanel>
<TextBlock Text="Reading Suggestion" FontWeight="Bold"/>
<TextBlock Text="Charles Dickens" Margin="5"/>
</StackPanel>
</ToolTip>
</Border.ToolTip>
</Border>
</DataTemplate>
But it doesn´t work. When I hover the Task elements (Border items) nothing happens. Any ideas what's wrong?
UPDATE
The Grid (x:Name="grid1") is contained in a custom control that handles zooming and padding. I implemented this following this post in codeplex (I followed the 'Simple Sample Code').
So my xaml looks like this:
<ScrollViewer
x:Name="scroller"
CanContentScroll="True"
VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible"
>
<!--
This is the control that handles zooming and panning.
-->
<ZoomAndPan:ZoomAndPanControl
x:Name="zoomAndPanControl"
Background="LightGray"
MouseDown="zoomAndPanControl_MouseDown"
MouseUp="zoomAndPanControl_MouseUp"
MouseMove="zoomAndPanControl_MouseMove"
MouseWheel="zoomAndPanControl_MouseWheel"
>
<!--
This Canvas is the content that is displayed by the ZoomAndPanControl.
Width and Height determine the size of the content.
-->
<Grid x:Name="grid1">
<ItemsControl x:Name="content"
ItemsSource="{Binding TaskItems}"
ItemContainerStyle="{StaticResource canvasTaskItemStyle}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas
Background="White"
Height="2000"
Width="2000"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<ItemsControl x:Name="contentLines"
ItemsSource="{Binding TaskLineItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas
Background="Transparent"
Height="2000"
Width="2000"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</ZoomAndPan:ZoomAndPanControl>
</ScrollViewer>
Are maybe the commands of the ZoomAndPanControl interfering with the tooltip?