0

使用 windowsphonetoolkit 如何在消息文本中强制换行以很好地格式化它。似乎标准的“\n”和“\n\r”换行符不起作用。

所以像:

This is the first line
and 
This is another line.

4

1 回答 1

0

您可以通过在Content属性中设置消息而不是Message. 那么消息可能只是一个TextBlock你可以做任何你想做的事情的地方。

如果您在 XAML 中执行自定义消息框,则可能如下所示:

<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>

但是你也可以在后面的代码中实现它:

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();

结果:
截屏

于 2015-03-03T09:23:09.857 回答