【问题标题】:Image Control with Tool Tip带有工具提示的图像控制
【发布时间】:2009-07-22 15:49:06
【问题描述】:

我正在 c# 中创建一个 WPF 应用程序,并且我有一个带有图像的图像控件。当鼠标悬停在ToolTip 上时,我希望它显示带有图像和文本的ToolTip。那么当鼠标悬停在ToolTip 上时,如何使用图像制作ToolTip。在此先感谢您的帮助。

【问题讨论】:

    标签: c# wpf image tooltip


    【解决方案1】:

    试试这样的。

    <!-- This is the image that has the tooltip -->
    <Image Source="...">
        <Image.ToolTip>
            <!-- A tooltip can contain any element.  Here we put a text
                 block and another image. -->
            <StackPanel>
                <TextBlock>This is the tooltip text</TextBlock>
                <!-- This image appears inside the tooltip -->
                <Image Source="..." />
            </StackPanel>
        </Image.ToolTip>
    </Image>
    

    【讨论】:

    • 呃那到底会去哪里?
    • 我知道它在 xaml 中,但有具体的地方吗?
    • 我编辑了答案以包括一些表明位置对您来说更好的 cmets。这有帮助吗?
    • 哇,这很有帮助。谢谢德鲁。还有一件事,我如何定位工具提示出现的位置以及如何将文本定位到我希望它出现的位置。非常感谢您的帮助。
    • ToolTip 有一个“Placement”属性,可用于定位。至于文本布局,这取决于您希望它的外观。如果您不熟悉 WPF 布局,则值得尝试使用 Kaxaml 之类的工具,并尝试使用内置布局面板:StackPanel、DockPanel、Grid、WrapPanel、Canvas 和 UniformGrid。恕我直言,该列表大致按有用性降序排列。
    猜你喜欢
    • 2012-11-14
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    相关资源
    最近更新 更多