覆盖两个控件 [英] Overlay two controls
问题描述
我开始做在WPF一些事情,我有一个问题。我认为答案可能很容易,甚至明显的,但不知为什么...
I started to make some thing in WPF and I have a question. I think the answer might be easy and even obvious, but somehow...
我有一个网格包围在窗体上的两个控件。我想要两个位置的第二控制上述第一个(它是透明的)。我来自的WinForms开发这并不难,所以它不会在WPF。但我不明白了吧...
I have two controls on a form enclosed by a grid. I want two position the second control above the first one (it's transparent). Coming from WinForms development that isn't that hard, so it won't be in WPF. But I don't get the point...
萨沙
推荐答案
无论是电网
和画布
控件会做你想要的。
Either the Grid
and Canvas
controls would do what you wanted.
在大多数情况下,我建议使用电网
叠加元素,还可以控制他们如何调整容易。他们会堆积在你定义的顺序(最后定义在顶部)。
For most cases I'd recommend using the Grid
to overlay elements, as you can also control how they resize easily. They'll stack in the order you define them (last defined at the top).
尝试是这样的:
<Grid>
<Rectangle Fill="Blue"/>
<Ellipse Fill="Red"/>
</Grid>
顺便说一句 - 学习XAML是很容易做的像一个互动的工具 Kaxaml
这篇关于覆盖两个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!