我有很长的字符串并在 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 行上并且没有换行。我如何在不为 ContentDialogResult 自定义 xaml 的情况下包装它。
感谢大家的支持!
ContentDialog接受任何对象作为标题和内容属性。所以,创建 TextBlock , 添加 TextWrapping属性并将其传递给 Content 而不是字符串对象。它会起作用。
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
};
我是一名优秀的程序员,十分优秀!