C# Windows Phone 8-StackPanel中的文本块未正确包装文本?

C# Windows Phone 8-StackPanel中的文本块未正确包装文本?,c#,xaml,windows-phone-8,word-wrap,textblock,C#,Xaml,Windows Phone 8,Word Wrap,Textblock,我有一个基于全景控制的应用程序。单击一个全景控件页面(选项卡)上的项目,将进入详细信息页面。在详细信息页面上,我有下面的XAML来呈现项目内容。如您所见,在phone:PanoramaItem.Header元素中有一个文本块,由堆栈面板承载。我希望该元素中的文本包装视图模型中绑定的TextBlock视频标题。我将TextWrapping设置为wrap,并为其指定了固定的宽度,以便TextBlock不会增长/扩展(因此不会进行包装)。文本确实是换行的,但有些行仍然显示为剪裁,有些词显示为“截断”。

我有一个基于全景控制的应用程序。单击一个全景控件页面(选项卡)上的项目,将进入详细信息页面。在详细信息页面上,我有下面的XAML来呈现项目内容。如您所见,在phone:PanoramaItem.Header元素中有一个文本块,由堆栈面板承载。我希望该元素中的文本包装视图模型中绑定的TextBlock视频标题。我将TextWrapping设置为wrap,并为其指定了固定的宽度,以便TextBlock不会增长/扩展(因此不会进行包装)。文本确实是换行的,但有些行仍然显示为剪裁,有些词显示为“截断”。我的XAML有什么问题

我读到关于使用DockPanel的内容:

但是这个应用程序有一个StackPanel用于许多不同的页面,所以如果我能坚持使用StackPanel我更喜欢它

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Grid Grid.Row="0" Visibility="{Binding IsInternetAvailable}" Background="{StaticResource PhoneAccentBrush}" Height="30">
        <TextBlock Text="{Binding Path=LocalizedResources.NoConnection, Source={StaticResource LocalizedStrings}}" Margin="10, 0"/>
    </Grid>
    <phone:Panorama x:Name="PanoramaFavorites_DetailVideos" Grid.Row="2" Foreground="{StaticResource CustomApplicationTextBrush}" Background="{StaticResource CustomApplicationBackgroundImage}" SelectionChanged="panoramaFavorites_DetailVideos_SelectionChanged">
        <phone:Panorama.Title>
            <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
                <Image Height="85" Width="85" Source="http://appstudiodata.blob.core.windows.net/apps/1383/db936107-bce6-41a2-9d95-1d342f66c6bb/res/Logo-b3883645-a6cd-4cc8-82be-97c87a266656.png" Stretch="Uniform" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="5,0,10,5" RenderTransformOrigin="0.5,0.5" />
                <TextBlock FontSize="92" Text="Robot Videos" FontFamily="Segoe WP Light" Foreground="{StaticResource CustomTitleApplicationTextBrush}" VerticalAlignment="Stretch"/>
            </StackPanel>
        </phone:Panorama.Title>
        <phone:PanoramaItem x:Name="PanoramaFavorites_DetailVideos0" Margin="0,0,0,25">
            <phone:PanoramaItem.Header>
                <StackPanel Orientation="Horizontal" Margin="0,7,0,0">
                    <TextBlock Text="{Binding CurrentYouTubeVideo.Title, Converter={StaticResource SanitizeString}}" Foreground="{StaticResource CustomApplicationTextBrush}" FontSize="36" TextWrapping="Wrap" Width="440" Height="170"/>
                </StackPanel>
            </phone:PanoramaItem.Header>
            <ctl:FlipControl NextElementCommand="{Binding NextpanoramaFavorites_DetailVideos0}" PreviousElementCommand="{Binding PreviouspanoramaFavorites_DetailVideos0}" ShowPreviousButton="{Binding HasPreviouspanoramaFavorites_DetailVideos0}" ShowNextButton="{Binding HasNextpanoramaFavorites_DetailVideos0}">
                <ctl:FlipControl.InnerContent>
            <Grid Margin="10,5,5,5">    
                <ScrollViewer>
                        <ctl:YouTubePlayer Margin="0,10" MaxHeight="250" VerticalAlignment="Top" VideoId="{Binding CurrentYouTubeVideo.VideoId, TargetNullValue={StaticResource DefaultNoImageValue}}"/>
                </ScrollViewer>
            </Grid>
                </ctl:FlipControl.InnerContent>
            </ctl:FlipControl>
        </phone:PanoramaItem>
    </phone:Panorama>
</Grid>

根据您的评论,这对我很有用:

<StackPanel Orientation="Vertical" Margin="0,7,0,0">
    <TextBlock Text="{Binding CurrentYouTubeVideo.Title, Converter={StaticResource SanitizeString}}" 
               Foreground="{StaticResource CustomApplicationTextBrush}" 
               FontSize="36" 
               TextWrapping="Wrap" 
               MaxWidth="440"/>
</StackPanel>

根据您的评论,这对我很有用:

<StackPanel Orientation="Vertical" Margin="0,7,0,0">
    <TextBlock Text="{Binding CurrentYouTubeVideo.Title, Converter={StaticResource SanitizeString}}" 
               Foreground="{StaticResource CustomApplicationTextBrush}" 
               FontSize="36" 
               TextWrapping="Wrap" 
               MaxWidth="440"/>
</StackPanel>


您正在指定它的确切大小,那么,当你给它的空间中有太多的文本时,你希望它如何表现呢?@steveg89我希望它使用分词符将文本换行到下一行,以决定当一个单词超过文本块的指定宽度时在何处进行换行。你指定了它的确切大小,那么,当你给它的空间中有太多的文本时,你希望它如何表现呢?@steveg89我希望它使用分词符将文本换行到下一行,以决定当一个单词超过文本块的指定宽度时,在何处进行换行。