ZIndex 和 Silverlight [英] ZIndex and silverlight
问题描述
我有一个构成问题主题的图像,我想在它上面放置按钮供用户点击.
I have an image which constitutes the subject of a question and I want to place buttons on top of it for the user to click.
我有一个定位精灵的对象(一个带有变换背景图像的矩形)
I have an object which positions a sprite (a rectangle with a background image which is transformed)
我有一个 ItemsControl,它使用 Margin.left 和 top 来定位按钮.像这样
And I have an ItemsControl which positions the buttons using Margin.left and top. Like so
<Grid x:Name="imageGrid">
<local:spriteView Canvas.ZIndex="10" x:Name="QuestionImage" Sprite="{Binding QuestionImageSprite}" />
<local:ImageAnswers Canvas.ZIndex="50" x:Name="AnswersImages" Answers="{Binding answers}"></local:ImageAnswers>
</Grid>
我希望 AnswerImages
直接位于 QuestionImage
之上,但 QuestionImage
将 AnswerImages
向下推并且 AnswerImages
也影响了 QuestionImage
的位置.
I want AnswersImages
to be positioned directly on top of QuestionImage
but QuestionImage
is pushing AnswerImages
down and AnswerImages
is also affecting the position of QuestionImage
.
我如何阻止他们这样做?我可以强制它们绝对定位在 ImageGrid
How do I stop them from doing that? Can I force them to be positioned absolutely within the ImageGrid
推荐答案
删除 Canvas.ZIndex
声明.如果您将它们都放在一个网格中而不指定额外的 Column 和 Row 定义,它们将按照它们在 XAML
Remove the Canvas.ZIndex
declarations. If your putting them both in a grid without specifying additional Column and Row definitions they will lay ontop of each other in the order they appear in the XAML
这篇关于ZIndex 和 Silverlight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!