Reputation: 61
Using the windowsphonetoolkit how can one force line breaks in the message text to nicely format it. It appears that the stardard "\n" and "\n\r" line breaks do not work.
So something like:
This is the first line
and
This is another line.
Upvotes: 0
Views: 90
Reputation: 1892
You can achieve that by setting your message in Content
property instead of Message
. Then the message could be just a TextBlock
where you can do whatever you want.
If you're doing your custom message box in XAML, the could look like this:
<toolkit:CustomMessageBox Caption="Caption"
LeftButtonContent="ok"
RightButtonContent="cancel">
<TextBlock Margin="12"
FontSize="{StaticResource PhoneFontSizeMedium}"
FontFamily="Segoe WP SemiLight">First line<LineBreak />Second line</TextBlock>
</toolkit:CustomMessageBox>
But you can also make it in code behind:
CustomMessageBox messageBox = new CustomMessageBox()
{
Caption = "Caption",
LeftButtonContent = "ok",
RightButtonContent = "cancel",
Content = new TextBlock()
{
Margin = new Thickness(12),
FontSize = (double)Resources["PhoneFontSizeMedium"],
FontFamily = new System.Windows.Media.FontFamily("Segoe WP SemiLight"),
Text = "First line" + Environment.NewLine + "Second line",
},
};
// messageBox.Show();
Result:
Upvotes: 0