The easiest way is to use Popup. Look at the sample code.
<Popup x:Name="InfoPopup" PlacementTarget="{Binding ElementName=yourElement}" AllowsTransparency="True" StaysOpen="False" Placement="Mouse" PopupAnimation="Fade"> <Border BorderBrush="White" BorderThickness="1" Background="#FFFFFFFF" > <Label Content="Your text here" /> </Border> </Popup> <Border x:Name="yourElement" Background="#FFFFFF" MinWidth="20" Height="20"> <Border.Triggers> <EventTrigger RoutedEvent="Mouse.MouseDown"> <BeginStoryboard> <Storyboard> <BooleanAnimationUsingKeyFrames Duration="0:0:0:0" Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="InfoPopup"> <DiscreteBooleanKeyFrame Value="True"></DiscreteBooleanKeyFrame> </BooleanAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="Mouse.MouseUp"> <BeginStoryboard> <Storyboard> <BooleanAnimationUsingKeyFrames Duration="0:0:0:0" Storyboard.TargetProperty="IsOpen" Storyboard.TargetName="InfoPopup"> <DiscreteBooleanKeyFrame Value="False"></DiscreteBooleanKeyFrame> </BooleanAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </EventTrigger> </Border.Triggers> </Border>
supertoha
source share