【问题标题】:c# uwp custom tooltip时间:2019-04-10 标签:c#uwp custom tooltip
【发布时间】:2017-12-02 22:25:43
【问题描述】:

在 C# UWP 中,有谁知道如何制作自定义工具提示,用箭头指向工具提示有界的控件。

像这样:


(来源:s-msft.com

我已尝试更改样式。

【问题讨论】:

标签: c# uwp tooltip


【解决方案1】:

注意:这个答案可能不是正确的方法,但它会起作用

方法一:

使用Polygon 绘制ToolTip 的边框。如果您想要弯曲的边缘,请使用Path。这是一个代码示例。

<Button Content="?" ToolTipService.Placement="Bottom">
    <ToolTipService.ToolTip>
        <ToolTip Background="Transparent" BorderThickness="0">
            <Grid>
                <Polygon Fill="Gainsboro" Points="0,20,0,120,200,120,200,20,110,20,100,0,90,20" Stroke="Black" StrokeThickness="2" />
                <StackPanel Margin="5,25,5,5">
                    <TextBlock Text="Information" FontSize="36" Foreground="Blue"/>
                    <TextBlock Text="This is a button" FontSize="18"/>
                </StackPanel>
            </Grid>
        </ToolTip>
    </ToolTipService.ToolTip>
</Button>

样本输出:

方法二:

您可以使用自定义设计的Image 作为ToolTip 的边框。不要忘记设置HorizontalAlignment="Stretch"VerticalAlignment="Stretch"。这是一个代码示例。

<Button Content="?" ToolTipService.Placement="Bottom">
    <ToolTipService.ToolTip>
        <ToolTip Background="Transparent" BorderThickness="0">
            <Grid>
                <Image Source="Assets/ToolTipImage.png" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                <StackPanel Margin="5,25,5,5">
                    <TextBlock Text="Information" FontSize="36" Foreground="Blue"/>
                    <TextBlock Text="This is a button" FontSize="18"/>
                </StackPanel>
            </Grid>
        </ToolTip>
    </ToolTipService.ToolTip>
</Button>

【讨论】:

  • 嗯,谢谢。这让我对如何继续我的工作有了更多的想法。
  • 我只需要计算显示箭头的位置。
猜你喜欢
  • 1970-01-01
  • 2016-04-19
  • 2022-01-16
  • 2018-07-04
  • 2019-06-02
  • 1970-01-01
  • 1970-01-01
  • 2013-05-26
  • 2015-02-10
相关资源
最近更新 更多