在TextBlock中显示完整数据

时间:2014-02-12 09:21:31

标签: c# .net layout windows-phone-8 textblock

我正在为WindowsPhone构建一个应用程序,我需要在TextBlock中显示数据。由于数据的大小很大,我使用ScrollBar来显示数据。我不想横向滚动。如果数据的大小很大,我想将它显示为带有垂直ScrollBar的段落。请看我的Xaml:

<Canvas Height="659" Background="White" HorizontalAlignment="Left" Margin="-40,91,0,0" Name="canvas2" VerticalAlignment="Top" Width="536">
            <Image Canvas.Left="76" Canvas.Top="26" Height="227" Name="newsimage" Stretch="Fill" Width="373" />
            <TextBlock Canvas.Left="76" Canvas.Top="274" Height="41" Name="datee" Text="" Width="200" Foreground="Green" FontFamily="Verdana" FontSize="24" />
           <ScrollViewer Margin="2,0,10,20"  VerticalScrollBarVisibility="Auto" AllowDrop="False" ManipulationMode="Control" Height="131" VerticalAlignment="Bottom" Canvas.Left="76" Canvas.Top="347">
                <TextBlock Canvas.Left="59" Canvas.Top="334" Height="124" Name="title" Text="" Width="410" Foreground="Black" FontFamily="Verdana" FontSize="24" FontWeight="Bold" />
           </ScrollViewer>

我希望最后一个TextBlock即“title”具有垂直滚动功能。在这里,我无法显示完整的数据;

1 个答案:

答案 0 :(得分:1)

TextWrapping属性设置为Wrap + VerticalScrollBarVisibility设置为可见而不是自动以强制垂直滚动:

<ScrollViewer Margin="0,0,0,476" VerticalScrollBarVisibility="Visible">
                <TextBlock TextWrapping="Wrap">
                            This is just a stupid long text
                            Adding supported languages in the Project Properties tab will
                            new resx file per language that can carry the translated                      
                            values of your UI strings. The binding in these examples will  
                            cause the value of the attributes to be drawn from the .resx 
                            file that matches CurrentUICulture of the app at run time.
                </TextBlock>
            </ScrollViewer>

这很好用