简体   繁体   English

在UserControl中居中标签

[英]Center a label in a UserControl

I have a WPF UserControl. 我有一个WPF UserControl。 I have inside a Label (autosized). 我有一个标签(自动调整)。

How I do for center the label in the middle of the UserControl? 我如何在UserControl中间将标签置于中心位置?

You can use attributes: VerticalAlignment and HorizontalAlignement with the "Center" value. 您可以使用属性:VerticalAlignment和Horizo​​ntalAlignement以及“Center”值。

Or you can have something like that: 或者你可以有类似的东西:

Label.Margin = String.Format("{0},0,0,0",UserControl.actualWidth/2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM