在我的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