Mahavirsinh Padhiyar
Mahavirsinh Padhiyar

Reputation: 1179

How to put LineBreak in dynamically created Label in WPF

I am using Visual Studio 2013 Ultimate and have Framework 4.5.

I am new to WPF and I am creating the label dynamically I mean in back end and I want to give the break line in given text to Label.

The code I have written is:

Label lblName = new Label();
lblName.Content = "FirstName LastName";

here I want to give break line between FirstName and LastName so my output will come like.

FirstName

LastName

but not like

FirstName LastName

So how to put in between FirstName and LastName a breakline.

Upvotes: 1

Views: 264

Answers (2)

Jeff Matthews
Jeff Matthews

Reputation: 48

Don't try to do that with a single label. Add a second label.

Upvotes: 0

Arun Selva Kumar
Arun Selva Kumar

Reputation: 2732

You could try as follows,

Label lblName = new Label(); 
lblName.Content = "FirstName" + Environment.NewLine + "LastName";

Upvotes: 2

Related Questions