How di I make a newline in the text for a checkbox? I've tried \n but it didn't work?
EDIT: this is my CheckBox
<CheckBox xml:space="preserve" Height="16" HorizontalAlignment="Left" Margin="360,46,0,0" Name="ShowOldRegistrations" VerticalAlignment="Top" Checked="ShowOldRegistrations_Checked" Unchecked="ShowOldRegistrations_UnChecked">
<StackPanel Height="42" Width="108">
<TextBlock>Line1</TextBlock>
<TextBlock>Line2</TextBlock>
</StackPanel>
</CheckBox>
<CheckBox Content="Stuff on line1
Stuff on line 2" />
You should not use a StackPanel for line-breaks, TextBlocks can do that easily:
<CheckBox>
<TextBlock>
<Run Text="Line 1"/>
<LineBreak/>
<Run Text="Line 2"/>
</TextBlock>
</CheckBox>
In WPF, you can put any control almost anywhere. So you could try this:
<CheckBox>
<StackPanel>
<TextBlock>foo</TextBlock>
<TextBlock>bar</TextBlock>
</StackPanel>
</CheckBox>
Also, you need to remove the Height
property from your checkbox. Of course only one line gets displayed if the height doesn't permit displaying more.
In WPF, in most cases you don't need to (nor should) specify absolute dimensions for your controls. They can adjust automatically quite well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With