wpf - 将鼠标悬停在 Silverlight 中的对象上时显示自定义工具提示?/弹出窗口

标签 wpf silverlight silverlight-4.0

当我悬停或单击 Silverlight 应用程序中的对象时,如何获得类似的弹出窗口/悬停/工具提示(见下图)?

更新: (增加赏金)

我正在寻找一个可以放置阴影并显示箭头的控件。我想要 3-4 行数据,我可以将它们作为控件的属性传入。

popup exampe http://www.freeimagehosting.net/uploads/4a78a786fc.gif

最佳答案

Expression Blend 4 具有这种标注形状,您可以应用 <DropShadowEffect/>到它。要将文本放入其中,只需将文本框和标注包裹在 Canvas 中即可。来自 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.



我使用了标注 - 非常方便,用法与 Office 中的自选图形非常相似。要做一个弹出窗口,你只需要一个简单的动画。

如果您没有表达式,您可以手动编码 XAML 以创建标注。这是我制作的一个示例:
<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>

标注的尾部与示例中的尾部不完全相同,阴影也不同,但可以更改不同的值以使其看起来尽可能接近示例。

关于wpf - 将鼠标悬停在 Silverlight 中的对象上时显示自定义工具提示?/弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3239100/

相关文章:

c# - 在 WPF 中使用通用 Windows 平台 (Windows 10) 控件

wpf - Caliburn Micro 中屏幕之间的滑动过渡动画

c# - 单击 Generic.xaml 中的按钮?

c# - DateTimePicker 只选择月份

c# - 如何在 Silverlight 中的附加依赖属性上设置 TypeConverter?

c# - 如何向分组的 WPF 数据网格项添加额外的属性计数?

c# - 组合框项目源 = ObservableCollection & 我需要在顶部有一个 '-None-' 虚拟条目

c# - 如何在 C#/WPF/XAML 中将整个对象而不只是一个属性绑定(bind)到组合框列表的控件?

wpf - 使用 Prism 时将应用程序的部分拆分为各自的程序集

wpf - 当文本开始超出边框时,是否可以缩放文本框中的文本大小?