在我的Windows Phone 7应用程序中,我必须添加多个列表框。我的要求是用户可以滚动页面查看所有项目。但我不知道如何在一个页面中添加多个列表框。我有这样的尝试。如何添加多个列表框中的Windows Phone 7
<Grid x:Name="testUIContainer" Grid.Row="1" Margin="2,0,2,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Visible"
MaxWidth="477">
<ScrollViewer.Content>
<StackPanel Margin="0, 30, 0, 0 ">
<Rectangle Height="50" Margin="0,0,0,0" Name="Header" Stroke="Black" StrokeThickness="1" Width="480" Grid.ColumnSpan="2" Fill="#FF01A1DB" />
<ListBox Grid.Row="0" ItemsSource="{Binding StudentDetails,Mode=TwoWay}" Margin="0,0,0,0" Name="listBox1" Width="476" BorderBrush="#00410D0D">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" Padding="5" BorderThickness="1">
<StackPanel Orientation="Horizontal" >
<Border BorderBrush="Wheat" BorderThickness="1">
<Image Name="ListPersonImage" Source="{Binding PersonImage}" Height="100" Width="100" Stretch="Uniform" Margin="10,0,0,0"/>
</Border>
<TextBlock Text="{Binding FirstName}" Name="firstName" Width="200" Foreground="White" Margin="10,10,0,0" FontWeight="SemiBold" FontSize="22" />
<TextBlock Text="{Binding LastName}" Name="lastName" Width="200" Foreground="White" Margin="-200,50,0,0" FontWeight="SemiBold" FontSize="22" />
<TextBlock Text="{Binding Age}" Name="age" Width="200" Foreground="White" Margin="10,10,0,0" FontWeight="SemiBold" FontSize="22" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox Grid.Row="1" ItemsSource="{Binding StudentDetails,Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,0,0,0" Name="listBoxes1" Width="476" BorderBrush="#00410D0D">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Gray" Padding="5" BorderThickness="1">
<StackPanel Orientation="Horizontal" >
<Border BorderBrush="Wheat" BorderThickness="1">
<Image Name="ListPersonImage" Source="{Binding PersonImage}" Height="100" Width="100" Stretch="Uniform" Margin="10,0,0,0"/>
</Border>
<TextBlock Text="{Binding FirstName}" Name="firstName" Width="200" Foreground="White" Margin="10,10,0,0" FontWeight="SemiBold" FontSize="22" />
<TextBlock Text="{Binding LastName}" Name="lastName" Width="200" Foreground="White" Margin="-200,50,0,0" FontWeight="SemiBold" FontSize="22" />
<TextBlock Text="{Binding Age}" Name="age" Width="200" Foreground="White" Margin="10,10,0,0" FontWeight="SemiBold" FontSize="22" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer.Content>
</ScrollViewer>
</Grid>
</Grid>
但是在这里我看不到第二个列表框。这仅仅是示例。我必须在页面中添加4到5列表框。请让我知道如何在一个页面中添加多个列表框。或者有任何其他选项可以显示项目列表。
我需求量的: -
你不能滚动到第二个'ListBox'或它不在吗?对'ListBox'也设置'Grid.Row =“0”'没有效果。 'ScrollViewer'是'Grid'的直接子节点,'ListBox'是'ScrollViewer'的子节点'StackPanel'的子节点。在你的情况下,整个'ScrollViewer'将在第一行 – dkozl
ListBox *是一种显示项目列表的方式,并且通常每个列表需要**一个**列表框。 –
@ user2845346,因为你设置了'Height =“Auto”'你的'ScrollViewer'被赋予尽可能多的空间,因为它需要增长以容纳所有的孩子,因此你将看不到滚动条。 – dkozl