c# - 我的滚动视图无法在Windows Phone 8.1中使用

c# - 我的滚动视图无法在Windows Phone 8.1中使用,第1张

我的Scrollview无法在Windows Phone 8.1中使用。这是我的代码。请帮我。您在其中看到的所有文本块都与我的数据库绑定。我从数据库中获取数据并在scrollviewer中显示。 建议我正确的代码。

<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>

最佳答案:

1 个答案:

答案 0 :(得分:0)

我看到了你的评论,我的代码示例如何对我有用,把它放在正确的位置,它应该有所帮助:

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

您可以根据需要使用参数,但HorizontalAlignmentVerticalAlignment很重要,请不要忘记设置它们。

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复