c# - 关于在 winphone 8.1 RT 中在 ContentDialogResult 中换行文本

标签 c# xaml windows-runtime windows-phone-8.1

我有很长的字符串并在 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
        };

关于c# - 关于在 winphone 8.1 RT 中在 ContentDialogResult 中换行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30137459/

相关文章:

c# - RunAsync - 如何等待 UI 线程上的工作完成?

c# - 用于收集的 Nhibernate 自定义加载器

c# - 如何在不发送电子邮件的情况下检查 smtp 服务器?

默认按钮上的 WPF 按钮内容 VerticalAlignment

c# - Windows Phone 弹出窗口始终位于顶部

windows-8 - 在模块 system.windows.dll 中找不到类型 system.windows.controls.control

c# - 使用 C#/XAML 在 Metro 风格应用程序中将 Canvas 保存为图像

c# - access 2007查询和c#数据表显示不同的输出

silverlight - Silverlight通过CustomControl后端代码按键访问资源

c# - WinRT 上 Windows.Foundation.Size.Width/.Height 中的 System.Double 类型