我有长字符串并在ContentDialogResult中显示为
var dlg = new ContentDialog()
{
Title = sTitle,
Content = "This is very long string and i want wrap it but it only appear in 1 line on content of ContentDialogResult. Please help me!",
PrimaryButtonText = sTextBtnMain,
SecondaryButtonText = sTextBtnSub
};
但它只显示在1行而没有换行。如何在没有自定义xaml for ContentDialogResult 的情况下包装。
感谢所有支持!
答案 0 :(得分:3)
ContentDialog接受任何对象作为标题和内容属性。因此,创建TextBlock,添加TextWrapping属性并将其传递给Content而不是string对象。它会工作。
TextBlock txtBlock = new TextBlock();
txtBlock.Text = "This is very long string and i want wrap it but it only appear in 1 line on content of ContentDialogResult. Please help me!";
txtBlock.TextWrapping = TextWrapping.Wrap;
ContentDialog dialog = new ContentDialog()
{
Title = sTitle,
Content = txtBlock,
PrimaryButtonText = sTextBtnMain,
SecondaryButtonText = sTextBtnSub
};