Add multiline content to button in c# windows phone 8.1

431 Views Asked by At

I have an app with some button which contains different text, of different length. When the text is longer than the width of the button, only the first part of the text is displayed. Is there a way to dynamically split the text in 2 lines or more? Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

Use TextBlock to define button content and set TextWrapping property.

<Button>
  <TextBlock TextWrapping="Wrap">your text</TextBlock>
</Button>
1
On

For specific breaks in your text I like to use Runs and LineBreaks

<Button>
  <TextBlock TextWrapping="Wrap" FontSize="9">
    <Run Text="Bind some text here" />
    <LineBreak/>
    <Run Text="Add some more text" />
  </TextBlock>
</Button>