serhio
serhio

Reputation: 28586

Center a label in a UserControl

I have a WPF UserControl. I have inside a Label (autosized).

How I do for center the label in the middle of the UserControl?

Upvotes: 1

Views: 858

Answers (1)

Arnaud Bessems
Arnaud Bessems

Reputation: 525

You can use attributes: VerticalAlignment and HorizontalAlignement with the "Center" value.

Or you can have something like that:

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

Upvotes: 4

Related Questions