在 Expression Blend、C#、WPF 中将用户控件置于前端
我有一个带有网格的窗口。
在此我有一些按钮,其中一个按钮在单击时将创建一个新的“PostIt”,这是我创建的用户控件。
我想做的是单击“PostIt”并将该控件置于所有其他控件之上。
我已经尝试过...
Grid.SetZIndex(sender, value);
这似乎是正确的代码,没有错误,只是控件没有移动:(
问题可能在于单击的代码位于用户控件中,而不是主窗口 cs 文件中。这重要吗?
“PostIt”只是一个带有文本框的边框。
I have a window with a Grid on.
On this I have some buttons, one of which when clicked will create a new 'PostIt' which is a user control I have created.
What I want to do is click on a 'PostIt' and have that control on top of all the others.
I have tried...
Grid.SetZIndex(sender, value);
Which seems to be the correct code, no errors, just not movement of the control :(
The problem may lie in the fact that the code for the click is in the user control and not the mainwindow cs file. Does this matter?
The 'PostIt' is simply a border with a text box in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是在 PostIt 鼠标单击的处理程序中调用 Grid.SetZIndex(sender, value) 还是在 PostIt 内的控件的处理程序中调用 Grid.SetZIndex(sender, value) ?您设置的值是多少?
这是一个有效的示例:
Jogy
Are you calling Grid.SetZIndex(sender, value) in a handler of the PostIt mouse click, or a handler for a control inside the PostIt? What is the value that you are setting?
Here is an example that works:
Jogy
这可能不是最好的解决方案,但它对我有用;我正在重新排序两个网格:
...将 GridOnBottom 和 GridOnTop 重命名为您要重新排序的对象的实例。当然,这不是最好的解决方案,但它确实有效。
This may not be the best solution, but it's the one that worked for me; I was re-ordering two grids:
...with GridOnBottom and GridOnTop renamed to the instances of the objects you're re-ordering. Granted, it's not the best solution, but it works.