wp7 scrollviewer列表框无法正常工作

时间:2012-07-13 01:53:27

标签: windows-phone-7 listbox scrollview

 <controls:PanoramaItem Header="Aylık" Foreground="White">
        <Grid x:Name="monthlyPanaromaGrid" >
            <Grid.Resources>
                <Style TargetType="ListBoxItem" x:Key="ListItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </Grid.Resources>
            <ScrollViewer HorizontalAlignment="Stretch" Height="Auto" VerticalAlignment="Stretch">
                <ListBox x:Name="monthlyItemListBox"  ScrollViewer.VerticalScrollBarVisibility="Auto" >
                    <ListBox.ItemTemplate >
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                                <TextBlock Text="{Binding Id}"  FontSize="24" />
                                <TextBlock Text="    " FontSize="24" />
                                <TextBlock Text="{Binding Name}" FontSize="24" />
                                <TextBlock Text="    " FontSize="24" />
                                <TextBlock Text="{Binding Surname}" FontSize="24" />
                                <TextBlock Text="    " FontSize="24" />
                                <TextBlock Text="{Binding Age}" FontSize="24" />
                                <TextBlock Text="    " FontSize="24" />
                                <TextBlock Text="{Binding Status}" FontSize="24" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </ScrollViewer>
        </Grid>
    </controls:PanoramaItem>

我尝试了50个成员的列表但是不能查看滚动查看器可能导致问题的原因?谢谢,我在这里看到了一些答案,我尝试了但没有工作(改变身高等等)谢谢。

1 个答案:

答案 0 :(得分:4)

ListBox已经有ScrollViewer,两个控件将对你的操作进行斗争。

移除ScrollViewer的外部ScrollViewer.VerticalScrollBarVisibility="Disabled",或设置ListBox上的TextBlocks以禁用滚动。

并且不确定您是否将Margin用于Margin,但您应该直接设置ColumnDefinitions,或使用Grid<controls:PanoramaItem Header="Aylık" Foreground="White"> <Grid x:Name="monthlyPanaromaGrid" > <Grid.Resources> <Style TargetType="ListBoxItem" x:Key="ListItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> </Style> </Grid.Resources> <ListBox x:Name="monthlyItemListBox" HorizontalAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Auto" > <ListBox.ItemTemplate > <DataTemplate> <Grid HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Text="{Binding Id}" Grid.Column="0" FontSize="24" /> <TextBlock Text="{Binding Name}" Grid.Column="1" FontSize="24" /> <TextBlock Text="{Binding Surname}" Grid.Column="2" FontSize="24" /> <TextBlock Text="{Binding Age}" Grid.Column="3" FontSize="24" /> <TextBlock Text="{Binding Status}" Grid.Column="4" FontSize="24" /> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </controls:PanoramaItem> }。

<controls:PanoramaItem Header="Aylık" Foreground="White">
        <Grid x:Name="monthlyPanaromaGrid" >
            <Grid.Resources>
                <Style TargetType="ListBoxItem" x:Key="ListItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </Grid.Resources>
                <ListBox x:Name="monthlyItemListBox" HorizontalAlignment="Stretch"  ScrollViewer.VerticalScrollBarVisibility="Auto" >
                    <ListBox.ItemTemplate >
                        <DataTemplate>
                            <Grid HorizontalAlignment="Stretch">
                              <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                              <ColumnDefinition Width="Auto" />
                              <ColumnDefinition Width="Auto" />
                              <ColumnDefinition Width="Auto" />
                              <ColumnDefinition Width="Auto" />
                              </Grid.ColumnDefinitions>

                                <TextBlock Text="{Binding Id}" Grid.Column="0" FontSize="24" />
                                <TextBlock Text="{Binding Name}" Margin="48,0,0,0" Grid.Column="1" FontSize="24" />
                                <TextBlock Text="{Binding Surname}" Margin="48,0,0,0" Grid.Column="2" FontSize="24" />
                                <TextBlock Text="{Binding Age}" Margin="48,0,0,0" Grid.Column="3" FontSize="24" />
                                <TextBlock Text="{Binding Status}" Margin="48,0,0,0" Grid.Column="4" FontSize="24" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
        </Grid>
    </controls:PanoramaItem>

{{1}}