ZIndex 和 silverlight
我有一个构成问题主题的图像,我想在其顶部放置按钮以供用户单击。
我有一个用于定位精灵的对象(一个带有已转换的背景图像的矩形)
,并且我有一个 ItemsControl,它使用 Margin.left 和 top 来定位按钮。就像这样,
<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>
我希望将 AnswersImages
直接定位在 QuestionImage
之上,但 QuestionImage
将 AnswerImages
向下推,AnswerImages
也会影响 QuestionImage
的位置。
我怎样才能阻止他们这样做?我可以强制它们绝对定位在 ImageGrid
内吗
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)
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>
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
.
How do I stop them from doing that? Can I force them to be positioned absolutely within the ImageGrid
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除 Canvas.ZIndex 声明。如果将它们放在网格中而不指定额外的列和行定义,它们将按照它们在
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 theXAML