Newline in a WPF-label? -


How can I add a new line in the text of a label in WPF such as the following?

  & lt; Label & gt; Corporate Advertising & lt; / Labels & gt;  

  & lt; Label & gt; & Lt; TextBlock & gt; Home & lt; Linereck / & gt; Ipsum & lt; / TextBlock & gt; & Lt; / Labels & gt;  

You have to use text block because textbox accepts children as a collection of inline objects. So you are giving the textbox element three inline items: run text = "home", lineback, and run text = "ipsum".

You can not do the following:

  & lt; Label & gt; Homepage & lt; Linereck / & gt; Ipsum & lt; / Labels & gt; ` 

Because a label accepts the basic element of a content.

Edit: Apart from this, not sure what are your use cases but the information that I have placed a TextBlock in your label element is it repetitive? In fact, there is a good article about the difference between the two elements based on your requirement:


Comments