WPF移动元素问题
我可能过度解决了一个非常简单的问题,但这就是我现在所遇到的:
我有几个按钮和一个项目列表框,用户可以在其中选择并与之交互。我的应用程序还根据应用程序宽度/高度移动这些元素,如下所示:
listBox1.Margin = new Thickness(this.ActualWidth * 0.84, this.ActualHeight * 0.3, 0, 0);
我能够在窗口模式下选择列表框中的项目并适当地单击按钮,但是当我开始将应用程序拉伸得更大时,我尝试单击这些项目,但我不能这样做..这是因为我也还需要更新他们的命中检测矩形吗?或者也许我错误地移动了物品?我不知所措……此时任何信息都会非常有帮助……谢谢!
I am probably over-doing a very simple problem, but this is what I have a the moment:
I have several buttons and a listbox of items in which the user can select and interact with. My application also moves those elements in accordance to the application width/height, such as follows:
listBox1.Margin = new Thickness(this.ActualWidth * 0.84, this.ActualHeight * 0.3, 0, 0);
I am able to select the items within the listbox and click on buttons appropriately while in windowed mode, but as I begin to stretch the application larger, I try to click on the items, and I cannot do so.. is this because I also need to update their hit-detection rectangles as well? Or perhaps am I moving the items incorrectly? I am at a loss.. any information would be very helpful at this point...thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知道为什么调整大小后无法再单击这些项目。这可能有很多原因。显然您希望列表框周围有比例的边距。您通常会使用网格来做到这一点:
Not sure why you can't click the items anymore after resizing. That can have a lot of reasons. Obviously you want to have proportional margins around the ListBox. You would normally do that with a Grid:
我
用这个代码隐藏
编写了这个 XAML:但我无法重现您的问题。检查我的代码是否与您的代码有不同之处并告诉我什么,以便我可以给您一些建议。谢谢
I write this XAML:
with this code-behind:
but I'm not able to reproduce your problem. Check my code if there is something different with your code and tell me what, so I can give you some advices. Thank you