Scrollviewer没有高度滚动

时间:2015-01-31 06:20:53

标签: c# xaml windows-phone windows-phone-8.1 scrollviewer

我正在编写Windows Phone 8.1应用程序(WINRT)。

我在页面中实现了 scrollviewer 。它包含 stackpanel ,其带有长文本的richtextblock 按钮

但问题是这个滚动查看器根本不滚动。如果我手动为此滚动查看器设置高度,则会滚动但在较高分辨率下看起来很难看。如何在没有手动高度的情况下使这个滚动查看器工作。

<ScrollViewer Name="WhyJoin_User_Content_Scroll"
                              Margin="0,10,0,10" 
                              VerticalScrollBarVisibility="Auto"
                              >
<StackPanel Orientation="Vertical">
    <RichTextBlock Name="WhyJoin_User_Content_RichTextBlock"
                    FontWeight="Light"
                    Margin="20,10,20,0" 
                    Foreground="{StaticResource DefaultTheme_DarkBlueColor}"
                    FontSize="19"
                    TextWrapping="Wrap"
                     TextAlignment="Justify">
        <RichTextBlock.Blocks>
            <Paragraph>
                <Paragraph.Inlines>
                    <Run Text=" Text Text Text Text Text Text Text Text ">
                    </Paragraph.Inlines>
                </Paragraph>
                <Paragraph>
                    <Paragraph.Inlines>
                        <Run Text=" Text Text Text Text Text Text Text Text ">
                        </Paragraph.Inlines>
                    </Paragraph>
                    <Paragraph>
                        <Paragraph.Inlines>
                            <Run Text=" Text Text Text Text Text Text Text Text "></Run>
                        </Paragraph.Inlines>
                    </Paragraph>
                    <Paragraph>
                        <Paragraph.Inlines>
                            <Run Text=" Text Text Text Text Text Text Text Text "></Run>
                        </Paragraph.Inlines>
                    </Paragraph>
                    <Paragraph>
                        <Paragraph.Inlines>
                            <Run Text="i: Practice work hours of experts"></Run>
                        </Paragraph.Inlines>
                    </Paragraph>
                    <Paragraph>
                        <Paragraph.Inlines>
                            <Run Text="ii: Address, Phone numbers etc."></Run>
                        </Paragraph.Inlines>
                    </Paragraph>
                    <Paragraph>
                        <Paragraph.Inlines>
                            <Run Text="iii: Appointment requests"></Run>
                        </Paragraph.Inlines>
                    </Paragraph>
                    <Paragraph>
                        <Paragraph.Inlines>
                            <Run Text=" Text Text Text Text Text Text Text Text "></Run>
                        </Paragraph.Inlines>
                    </Paragraph>
                </RichTextBlock.Blocks>
            </RichTextBlock>
            <Button 
                        x:Name="ButtonWhyJoin_User_Register"    
                        BorderThickness="0"
                        Width="150"   
                        Height="70"
                            Margin="0,10,0,0"
                            HorizontalAlignment="Center"

                        Click="ButtonWhyJoin_User_Register_Click"
                        FontWeight="ExtraLight"
                        Background="{StaticResource DefaultTheme_DarkBlueColor}" 
                        BorderBrush="{x:Null}" 
                        Style="{StaticResource ButtonStyleYesNo}"  
                        Foreground="{StaticResource DefaultTheme_BackgroundColor}"/>
        </StackPanel>
    </ScrollViewer>

1 个答案:

答案 0 :(得分:0)

解决问题的最简单方法是将滚动查看器的高度和/或宽度绑定到ContentRoot。这在Blend中最容易完成,无论屏幕分辨率如何,您都可以自动达到所需的高度。

http://pho.to/8kh1T

这就是XAML的样子

<ScrollViewer HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" Width="175" Height="{Binding ActualHeight, ElementName=ContentRoot}"/>