如何在鼠标悬停时显示矩形?

发布于 2024-12-02 12:20:10 字数 72 浏览 5 评论 0原文

简而言之,当用户将鼠标移动到矩形内部时,如何显示矩形,我必须显示用户控件。

我不知道该怎么做。感谢社区所做的一切。

In a few words, how do I show a rectangle when the user moves the mouse over, inside of the rectangle I must show a user control.

I have no idea how to do that. Thanks for everything community.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜兔 2024-12-09 12:20:10

如果您的意思是用户控件应始终可见,而矩形仅应在鼠标悬停在其上方时可见?然后就可以了:(边框用于在另一个控件周围绘制一个矩形。)

<Border Border.Background="Transparent" Border.BorderThickness="3">
    <Border.Style>
        <Style>
            <Setter Property="Border.BorderBrush" Value="Transparent"/>
            <Style.Triggers>
                <Trigger Property="Border.IsMouseOver" Value="True">
                    <Setter Property="Border.BorderBrush" Value="Green" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Border.Style>
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="X" />
</Border>

(使边框背景透明,以便捕获边框内的鼠标事件)

If you mean that the user control should be seen all the time and the rectangle should only be seen when the mouse is over it? Then this works: (Border is used to draw a rectangle round another control.)

<Border Border.Background="Transparent" Border.BorderThickness="3">
    <Border.Style>
        <Style>
            <Setter Property="Border.BorderBrush" Value="Transparent"/>
            <Style.Triggers>
                <Trigger Property="Border.IsMouseOver" Value="True">
                    <Setter Property="Border.BorderBrush" Value="Green" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Border.Style>
    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="X" />
</Border>

(Make the border background transparent in order to capture mouse events inside the border)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文