PivotItem ScrollViewer can't scroll down

2019-06-13 18:57发布

问题:

PivotItem ScrollViewer can't scroll down

For whatever the reason just won't scroll down when content that is bound inside the pivot item is longer than the height of the page. I tried adding a grid inside the pivotitem with height set to auto, but to no avail.

<controls:PivotItem>
                    <controls:PivotItem.Header>
                        <Grid>
                            <TextBlock Name="TextBlockPropertyDetail" FontSize="31" Text="Property Detail" />
                        </Grid>
                    </controls:PivotItem.Header>
                    <ScrollViewer>
                            <Grid Height="Auto">
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock1" Text="Property Id" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,41,0,0" Name="textBlock2" Text="County" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,77,0,0" Name="textBlock3" Text="Parcel Number" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,113,0,0" Name="textBlock4" Text="Market Value" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,149,0,0" Name="textBlock5" Text="Document Image" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,185,0,0" Name="textBlock6" Text="Value Range" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" Margin="12,221,279,0" Name="textBlock7" Text="Insured" VerticalAlignment="Top" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,257,0,0" Name="textBlock8" Text="Case Number" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,293,0,0" Name="textBlock9" Text="Recording Date" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,329,0,0" Name="textBlock10" Text="Recording Book" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,365,0,0" Name="textBlock11" Text="Recording Page" VerticalAlignment="Top" Width="189" Foreground="Black" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,5,0,0" Name="tbkPropertyId" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,41,0,0" Name="tbkCounty" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,77,0,0" Name="tbkParcelNo" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,113,0,0" Name="tbkMarketValue" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,149,0,0" Name="tbkDocumentImage" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,185,0,0" Name="tbkValueRange" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,221,0,0" Name="tbkInsured" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,257,0,0" Name="tbkCaseNo" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,293,0,0" Name="tbkRecordingDate" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,329,0,0" Name="tbkRecordingBook" Text="Loading..." VerticalAlignment="Top" Width="189" />
                                <TextBlock Foreground="Black" Height="30" HorizontalAlignment="Left" Margin="241,365,0,0" Name="tbkRecordingPage" Text="Loading..." VerticalAlignment="Top" Width="189" />
                            </Grid>
                    </ScrollViewer>
                </controls:PivotItem>

Thanks for any advice.

回答1:

Use the Stackpanel in the grid Element and try this.

  <controls:Pivot Title="MY APPLICATION">
        <!--Pivot item one-->
        <controls:PivotItem Header="first" Height="580" >
            <!--Double line list with text wrapping-->
            <ScrollViewer>
                <Grid>
                    <StackPanel>
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock1" Text="Property Id" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock2" Text="County" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock3" Text="Parcel Number" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock4" Text="Market Value" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock5" Text="Document Image" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock6" Text="Value Range" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" Margin="12,5,279,0" Name="textBlock7" Text="Insured" VerticalAlignment="Top" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock8" Text="Case Number" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock9" Text="Recording Date" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock10" Text="Recording Book" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlock11" Text="Recording Page" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-385,0,0" Name="tbkPropertyId" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-350,0,0" Name="tbkCounty" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-315,0,0" Name="tbkParcelNo" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-275,0,0" Name="tbkMarketValue" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-240,0,0" Name="tbkDocumentImage" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-205,0,0" Name="tbkValueRange" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-170,0,0" Name="tbkInsured" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-135,0,0" Name="tbkCaseNo" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-100,0,0" Name="tbkRecordingDate" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-65,0,0" Name="tbkRecordingBook" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-30,0,0" Name="tbkRecordingPage" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlsock1" Text="Property Id" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textsBlock2" Text="County" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBslock3" Text="Parcel Number" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textsBlock4" Text="Market Value" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textsBlock5" Text="Document Image" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textsBlock6" Text="Value Range" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlocsk7" Text="Insured" VerticalAlignment="Top" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBslock8" Text="Case Number" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBslock9" Text="Recording Date" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBlsock10" Text="Recording Book" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,5,0,0" Name="textBsock11" Text="Recording Page" VerticalAlignment="Top" Width="189" Foreground="White" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-380,0,0" Name="tbkPropsertyId" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-345,0,0" Name="tbkCosunty" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-310,0,0" Name="tbkPasrcelNo" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-275,0,0" Name="tbkMsarketValue" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-240,0,0" Name="tbkDsocumentImage" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-205,0,0" Name="s" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-170,0,0" Name="tsbkInsured" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-135,0,0" Name="tbskCaseNo" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-100,0,0" Name="tbskRecordingDate" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-70,0,0" Name="tbksRecordingBook" Text="Loading..." VerticalAlignment="Top" Width="189" />
                        <TextBlock Foreground="White" Height="30" HorizontalAlignment="Left" Margin="241,-35,0,0" Name="tbkRsecordingPage" Text="Loading..." VerticalAlignment="Top" Width="189" />
                    </StackPanel>
                </Grid>
            </ScrollViewer>
        </controls:PivotItem>
 </controls:Pivot>

And I hope you will get the Solution.