[UWP] [Xaml] UWP:内容对话框的大小和文本换行问题 [英] [UWP][Xaml]UWP: Size and Text Wrap issue of Content Dialog

查看:303
本文介绍了[UWP] [Xaml] UWP:内容对话框的大小和文本换行问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


VS2017 | UWP 


我想在MessageDialog()中显示图标,但似乎该选项不可用。 所以我看了ContentDialog。 但是ContentDialog的问题在于它的尺寸太小而且根据内容不会自动调整大小。 另外
它不包裹内容。   它证明很难做简单的事情。 我相信其他人也必须面对类似的问题,你建议采用什么解决方案?


下面是我的XAML代码和输出图像。





  Title =" TITLE"

    PrimaryButtonText = QUOT确定]; FullSizeDesired =" False"

    PrimaryButtonClick =" ContentDialog_PrimaryButtonClick"

>

  &NBSP; <网格和NBSP;高度= QUOT;自动" >

  &NBSP; &NBSP; &NBSP; < StackPanel Orientation =" Horizo​​ntal" 高度= QUOT;自动" >

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < TextBlock x:Name =" Image" 的FontFamily = QUOT;宋体"字号= QUOT; 40"前景= QUOT;绿色"文本= QUOT;&安培;#X4A;"保证金=" 5" />

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < StackPanel Orientation =" Vertical" 高度= QUOT;自动" >

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < TextBlock x:Name =" MessageText1"文本= QUOT;。" TextWrapping = QUOT; WrapWholeWords"&NBSP;余量= QUOT; 5,0,0,0"的Horizo​​ntalAlignment = QUOT;左"高度= QUOT;自动" />

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < TextBlock x:Name =" MessageText2"文本= QUOT;。" TextWrapping = QUOT; WrapWholeWords"&NBSP;余量= QUOT; 5,0,0,0"的Horizo​​ntalAlignment = QUOT;左"高度= QUOT;自动"&NBSP;
/>

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < / StackPanel>

  &NBSP; &NBSP; &NBSP; < / StackPanel>

  &NBSP; < /网格和GT;


请注意:   TextWrapping =" Wrap"也试过,但输出保持不变。它不包装内容。文件路径未完全显示。


解决方案


是的,在我的测试中,TextBlock不会使用您的代码片段扭曲ContentDialog中的文本。检查实时可视树后,我发现关键是你需要定义TextBlock的宽度。如果没有,TextBlock将自动获得一个适合文本长度的宽度
。 


所以我建议您可能需要设置TextBlock的宽度200并运行应用程序,你可以看到文本被包装。


对于图标的大小,它不是图像控件,它由字体大小决定。你需要定义字体大小来改变图标的​​大小。 


祝你好运,


Roy


Hi,

VS2017 | UWP 

I wanted to display icons in MessageDialog(), but it seems the option is not available.  So i looked at ContentDialog.  But The problem with ContentDialog is that its size is too small and does not auto-resize based on contents.  Also it does not Wrap Contents.   Its proving very difficult to do simple thing.  I am sure others too must be facing similar issue, What solution do you suggest ?

below is my XAML code and output image.

 Title="TITLE"
    PrimaryButtonText="OK" FullSizeDesired="False"
    PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
>
    <Grid  Height="Auto" >
        <StackPanel Orientation="Horizontal"  Height="Auto" >
            <TextBlock x:Name="Image"  FontFamily="Wingdings" FontSize="40" Foreground="Green" Text="&#x4A;" Margin="5"/>
            <StackPanel Orientation="Vertical"  Height="Auto" >
                <TextBlock x:Name="MessageText1" Text="." TextWrapping="WrapWholeWords"  Margin="5,0,0,0" HorizontalAlignment="Left" Height="Auto" />
                <TextBlock x:Name="MessageText2" Text="." TextWrapping="WrapWholeWords"  Margin="5,0,0,0" HorizontalAlignment="Left" Height="Auto"  />
            </StackPanel>
        </StackPanel>
    </Grid>

Please Note:  TextWrapping="Wrap" is also tried, but output remains the same. it does not wrap contents. The file path is not fully displayed.

解决方案

Hi,

Yep, in my test, the TextBlock does not warp the text in the ContentDialog using your code snippet. After checking the Live Visual Tree, I found the key is that you need to define the width of the TextBlock. If not, the TextBlock will get a width suitable for the length of the text automatically. 

So I suggest that you might need to set the width of the TextBlock like 200 and run the app you could see the text is wrapped.

For the size of the Icon, it is not a image control and it is determined by the font size. You need to define the font size to change the size of the icon. 

Best regards,

Roy


这篇关于[UWP] [Xaml] UWP:内容对话框的大小和文本换行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆