[英]WPF setting parent of label in WPF
I have being using winforms for a long time, my project friends from university decided to change project forms to wpf. 我使用Winforms已经很长时间了,我来自大学的项目朋友决定将项目表单更改为wpf。 I have 3 questions
我有3个问题
how do I set a parent of label? 如何设置标签的父项?
labels[i].Parent = GroupLabelBox; (for my winforms)
Second createcontrol function 第二个createcontrol函数
labels[i].CreateControl();
third one is bringtofront 第三个是前线
labels[i].BringToFront();
Do you have any suggestion how can I determine difference on msdn which methods or parameters use for wpf or forms? 您有什么建议,我该如何确定msdn上用于wpf或表单的方法或参数的差异? (it would be nice for future cases )
(这对将来的情况很好)
yourParent.Children.Add(yourlabel);
as far as i know you cant set a parent but a children 据我所知,你不能让一个父母,但要一个孩子
msdn: https://msdn.microsoft.com/en-us/library/system.windows.controls.panel.children%28v=vs.110%29.aspx msdn: https : //msdn.microsoft.com/zh-CN/library/system.windows.controls.panel.children%28v=vs.110%29.aspx
for the secont part you can cange the ZIndex of your label: How do I bring an item to the front in wpf? 对于第二部分,您可以取消标签的ZIndex: 如何在wpf中将项目放到最前面?
Canvas.SetZIndex(yourlabel, 1);
msdn: https://msdn.microsoft.com/en-us/library/system.windows.controls.panel.setzindex%28v=vs.110%29.aspx msdn: https : //msdn.microsoft.com/zh-CN/library/system.windows.controls.panel.setzindex%28v=vs.110%29.aspx
to bring an label to the front i would just set the ZIndex to something low (i think lower means front, i may be wrong) 将标签带到前面,我只是将ZIndex设置为较低(我认为较低意味着前面,我可能是错的)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.