Home > Net >  C # in the WPF dynamically add Label control, how to set up a text location and word wrap
C # in the WPF dynamically add Label control, how to set up a text location and word wrap

Time:12-05

In c # WPF, dynamic add Label controls, how to set up the position of the word, word wrap
Label pt=new Label ();
La1. The Content="test word";
La1. Width=400;
La1. Height=50;
La1. FontSize=20;
.//text center
.//word wrap

La1. Margin=new Thickness (0, 0, 0, 0);//in the position of the parent container

CodePudding user response:

You actually write the difference but actually, nothing but is to center the text attribute assignment,
If not clear effect, you can now write a Label control and to the properties of interface assignment,
The desired effect, and then the attribute assigned to pt.

CodePudding user response:

La1. AutoSize=false; (Label box height their definition)

CodePudding user response:

La1 is what, I only see pt is the label

CodePudding user response:

Several attribute is set to try

CodePudding user response:

In XML using HorizontalContentAlignment="Center"
The available code don't know how to do

CodePudding user response:

Try, code is always wrong
  •  Tags:  
  • C#
  • Related