简体   繁体   English

关于在winphone 8.1 RT中的ContentDialogResult中的换行文本

[英]about wrap text in ContentDialogResult in winphone 8.1 RT

I have long string and show it in ContentDialogResult as 我有很长的字符串,并在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
        };

but it only show on 1 line and no wrap. 但它只显示在1行而没有换行。 How i can wrap it without custom xaml for ContentDialogResult . 如何在没有ContentDialogResult的自定义xaml的情况下包装它。

Thanks for all support! 感谢所有支持!

ContentDialog accepts any object as Title and Content property. ContentDialog接受任何对象作为Title和Content属性。 So, create TextBlock , add TextWrapping property and pass it to Content instead of string object. 因此,创建TextBlock ,添加TextWrapping属性并将其传递给Content而不是string对象。 It will work. 它会工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM