开发者

How can I show a rectangle on mouse over?

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.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜