WPF TextBlock重叠椭圆 [英] WPF TextBlock Overlaps Ellipse

查看:38
本文介绍了WPF TextBlock重叠椭圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在WPF中创建它(我意识到我可以只使用图像,但是我正在尝试学习WPF):

I am trying to create this in WPF (I realize I could just use an image, but I am trying to learn WPF):

(来源)

到目前为止,这是我所能得到的,但未产生预期的结果,因为文本框似乎完全隐藏了椭圆,而它应该只是具有透明背景:

This is what I have so far but it isn't producing the desired result, in that, the textbox seems completely hide the ellipse whereas it should simply have a transparent background:

<StackPanel>
    <TextBlock HorizontalAlignment="Left" Margin="144,207,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
    <Ellipse HorizontalAlignment="Left" Height="52" Margin="142,189,0,0" Stroke="Black" VerticalAlignment="Top" Width="52"/>
</StackPanel>

推荐答案

您可以将这样的事情放在视图框中,以使缩放更容易,例如这样.您需要删除堆叠面板,它将要堆叠的物品一个堆叠在另一个之上,而这并不是您想要的.在这种情况下,我使用了网格.

You can put things like this in a viewbox to make scaling easier, something like this. You'll need to remove the stack panel, it's going to stack items one on top of the other which isn't what you're after here. I used a grid in this case.

<Viewbox Width="100" Height="100">
    <Grid Width="20" Height="20">
        <Ellipse Stroke="Black"/>
        <TextBlock HorizontalAlignment="Center" Text="i" TextAlignment="Center" VerticalAlignment="Center"/>
    </Grid>
</Viewbox>

这篇关于WPF TextBlock重叠椭圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆