views:

360

answers:

2

How can I go about getting similar popup/hover/tooltip (see image below) when I hover or click on an object in my Silverlight app?

Update: (added bounty)

I am looking for a control which can drop a shadow and show the arrow. I want like 3-4 lines of data which I can pass in as the control's properties.

popup exampe

+2  A: 
Klinger
Thanks, for the response. I was trying to use the ToolTipService, but is there a way to show the Arrow going from the point to the where the tooltip opens up and make it look pretty.
VoodooChild
@VoodooClild: I believe you can get something very close. ExpressionBlend is your friend here i think. I am not very skilled on XAML effects so I can't help you much more.If you haven't done it already try posting a message on the Expression forum: http://social.expression.microsoft.com/Forums/en-US/categories.There is also a Designing with Silverlight forum: http://forums.silverlight.net/forums/19.aspx
Klinger
+4  A: 

Expression Blend 4 has this kind of callout shape and you can apply a <DropShadowEffect/> to it. To put text inside, just wrap a textbox and the callout in a canvas. From this site:

Expression Blend 4 now includes presets for the easy creation of arcs, arrows, callouts, and polygons. Shapes can be easily switched between sketch-style and regular-style rendering. This feature can be found in the Assets panel under the new Shapes category.

I've used the callouts - very handy and very similar in usage to AutoShapes in Office. To do a pop-up, you'll just need a simple animation.

If you don't have Expressions, you could hand-code the XAML for creating the callout. Here's an example of one that I made:

<Path x:Name="Callout" Height="218" Width="197" Stroke="Black" StrokeThickness="2" Fill="WhiteSmoke" Canvas.Top="60" Canvas.Left="53" Stretch="Fill">
    <Path.Effect>
        <DropShadowEffect ShadowDepth="50" Opacity="0.25" BlurRadius="10"  />
    </Path.Effect>
    <Path.Data>
        <PathGeometry>
          <PathGeometry.Figures>
            <PathFigure StartPoint="0 21.1" IsClosed="True">
              <PathFigure.Segments>
                <ArcSegment Point="21.1 0" Size="21.1 21.1" SweepDirection="Clockwise" />
                <LineSegment Point="31.66 0" />
                <LineSegment Point="79.14 0" />
                <LineSegment Point="168.83 0" />
                <ArcSegment Point="189.93 21.1" Size="21.1 21.1" SweepDirection="Clockwise" />
                <LineSegment Point="189.93 73.86" />
                <LineSegment Point="189.93 105.52" />
                <ArcSegment Point="168.83 126.62" Size="21.1 21.1" SweepDirection="Clockwise" />
                <LineSegment Point="79.14 126.62" />
                <LineSegment Point="30.57 213.21" />
                <LineSegment Point="31.66 126.62" />
                <LineSegment Point="21.1 126.62" />
                <ArcSegment Point="0 105.52" Size="21.1 21.1" SweepDirection="Clockwise" />
                <LineSegment Point="0 105.52" />
                <LineSegment Point="0 73.86" />
              </PathFigure.Segments>
            </PathFigure>
          </PathGeometry.Figures>
        </PathGeometry>
    </Path.Data>
</Path>

The callout's tail isn't exactly like the one in the sample and the dropshadow is also different, but different values can be changed to try to make it look as close as possible to the sample.

Otaku
I don't have Expression Blend 4, is there a way to do it on plain XAML code. Could you provide examples please? -thanks
VoodooChild
@VoodooChild: I've provided a sample of a callout in plain XAML in the edit above.
Otaku
+1 I am going to try this out this weekend. Thanks, will reward the points soon...
VoodooChild
@Otaku: I used this callout with few modifications, thanks for putting it up. Just one more question, I put this in a separate UserControl _CalloutUC - how can I display this user control on my mouse point from a different user control? Right now I can display the callout but it doesn't show where I want it, wondering if you know how to do it?
VoodooChild
@VoodooChild: Good to hear this worked for you. You may want to open another question on displaying the callout so the whole community has a chance to provide an answer.
Otaku