我的滚动视图在windows phone 8.1中不工作

本文关键字:工作 phone 滚动 视图 windows 我的 | 更新日期: 2023-09-27 18:04:46

我的滚动视图在windows phone 8.1中不工作。这是我的代码。请帮帮我。你看到的所有文本块都与我的数据库绑定。我从数据库中获取数据,并显示在滚动查看器。建议我正确的代码。

<phone:PivotItem Header="Market Status">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Button x:Name="btnRefresh" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Bottom" Width="80" Height="80" BorderBrush="Transparent" Click="btnRefresh_Click">
                    <Button.Background>
                        <ImageBrush ImageSource="/Assets/Icons/refresh2.png"/>
                    </Button.Background>
                </Button>
                <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="20,10,20,10" Grid.Row="1">
                    <StackPanel.Background>
                        <ImageBrush ImageSource="/Assets/Icons/bg-market-highlight.png"/>
                    </StackPanel.Background>
                    <StackPanel Margin="10,20,10,0">
                        <StackPanel.Background>
                            <ImageBrush ImageSource="/Assets/Icons/market-status-bar.png"/>
                        </StackPanel.Background>
                        <StackPanel x:Name="Stack_DateTimeNStatus" Orientation="Horizontal" >
                            <TextBlock Text="Status:" FontSize="22" Foreground="Black" Margin="10,0,10,0" />
                            <TextBlock x:Name="txbMarketStatus" Text="{Binding MarketStatus}" FontSize="22" Foreground="Black" Width="85" />
                            <TextBlock x:Name="txbDate" Text="{Binding DateTime}" FontSize="22" Width="210" TextAlignment="Right" HorizontalAlignment="Right" Foreground="Black" Margin="5,0,0,0" />
                        </StackPanel>
                    </StackPanel>
                    <StackPanel x:Name="Stack_ListBox_MarketHighlights" Margin="0,10,0,10">
                        <ListBox x:Name="ListBox_MarketHighlights" ItemsSource="{Binding}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                            <ListBox.ItemTemplate>
                                <DataTemplate x:Name="DataTemplate_MarketHighlights">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock x:Name="txb_Title_Value" Width="250" Foreground="Black" HorizontalAlignment="Left" Text="{Binding Title}" Margin="10,0,10,0" />
                                        <TextBlock x:Name="txb_Value_Value" Width="125" Foreground="Black" HorizontalAlignment="Right" TextAlignment="Right"  Text="{Binding Value}" Margin="0,0,10,0" />
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>
                </StackPanel>
                <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="20,10,20,10" Grid.Row="2">
                    <StackPanel.Background>
                        <ImageBrush ImageSource="/Assets/Icons/bg-market-highlight.png"/>
                    </StackPanel.Background>                       
                    <StackPanel x:Name="Stack_ListBox_Favorite" Margin="0,10,0,10">
                        <StackPanel Margin="10,10,10,0">
                            <StackPanel.Background>
                                <ImageBrush ImageSource="/Assets/Icons/market-status-bar.png"/>
                            </StackPanel.Background>
                            <StackPanel Orientation="Horizontal" >
                                <!--<TextBlock Text="Industry" FontSize="22" Foreground="Black" Width="180" Margin="10,0,10,0" />-->
                                <TextBlock Text="Symbol" FontSize="22" Foreground="Black" Width="250" Margin="10,0,0,0" />
                                <TextBlock Text="Change" FontSize="22" Width="125" TextAlignment="Right" HorizontalAlignment="Right" Foreground="Black" Margin="0,0,10,0" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Margin="0,10,0,10">
                            <ScrollViewer>
                                <ListBox x:Name="ListBox_Favorite" ItemsSource="{Binding}" VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate >
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock x:Name="txb_Symbol_Name"  Foreground="Black" Width="250" HorizontalAlignment="Left" TextAlignment="Left"  Text="{Binding Symbol_Name}" Margin="10,0,10,0" Grid.Column="0" />
                                                <TextBlock x:Name="txb_Change_Value" Foreground="Black" Width="125" HorizontalAlignment="Right" TextAlignment="Right"  Text="{Binding CHANGE}" Margin="0,0,0,0" Grid.Column="1"/>
                                                <!--<StackPanel Orientation="Horizontal">-->
                                                <!--<TextBlock x:Name="txb_Industry_Name" Width="180" Foreground="Black" HorizontalAlignment="Left" Text="{Binding Industry_Name}" Margin="10,0,10,0" />-->
                                                <!--<TextBlock x:Name="txb_Symbol_Name"  Foreground="Black" Width="250" HorizontalAlignment="Left" TextAlignment="Left"  Text="{Binding Symbol_Name}" Margin="10,0,0,0" />
                                                <TextBlock x:Name="txb_Change_Value" Foreground="Black" Width="125" HorizontalAlignment="Right" TextAlignment="Right"  Text="{Binding CHANGE}" Margin="0,0,10,0" />
                                            </StackPanel>-->
                                            </StackPanel>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </ScrollViewer>
                            <TextBlock x:Name="txbNoRecordes" Text="No Record Found" Visibility="Collapsed" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="30" Grid.Row="0" Margin="20,0,0,0" Foreground="Black"/>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </Grid>
        </phone:PivotItem>

我的滚动视图在windows phone 8.1中不工作

我看到了你的评论,我有我的代码示例它是如何为我工作的,把它放在正确的地方,它应该有帮助:

    <ScrollViewer Padding="20" HorizontalAlignment="Center">
               <ListBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                      ....
               </ListBox>
   </ScrollViewer>

你可以随意设置参数,但HorizontalAlignmentVerticalAlignment很重要,不要忘记设置它们