我想显示另一个列表中的列表。 Windows Phone。 图为我想要的项目。 Image here
<Grid x:Name="Layout">
<TextBox Height="80" Width="340" InputScope="Search" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Image Source="/Assets/pesquisa.png" Height="76" Width="76" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<phone:LongListSelector Margin="0,80,0,0" x:Name="Conteudo" SelectionChanged="GoToPageDetalhes">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Nome}" Margin="10,5,0,0" />
<TextBlock Text="{Binding Alimentos}" Margin="10,5,0,0" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>
我感谢任何帮助。
答案 0 :(得分:0)
您所要做的就是为第一个DataTemplate
定义LongListSelector
。
假设您有一个国家/地区列表,并且每个国家/地区都包含城市列表:
public class Country
{
public Country(string name)
{
Name = name;
Cities = new List<City>();
}
public string Name { get; set; }
public List<City> Cities { get; set; }
}
public class City
{
public City(string name)
{
Name = name;
}
public string Name { get; set; }
}
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
Countries = new ObservableCollection<Country>(CreateCountries());
DataContext = this;
}
public ObservableCollection<Country> Countries { get; set; }
}
您可以为包含LongListSelector
的国家/地区创建LongListSelector
,其中包含以下城市:
<phone:LongListSelector x:Name="countries" ItemsSource="{Binding Countries}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}"/>
<phone:LongListSelector x:Name="cities" ItemsSource="{Binding Cities}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
我非常怀疑这会提供一个用户友好的界面。
答案 1 :(得分:0)
我认为您应该从Windows Phone Toolkit查看ExpanderView。看起来它正是您正在寻找的。 p>
Here是一些正确使用它的教程。
答案 2 :(得分:0)
谢谢你们,它很有用。 ExpanderView也很有用。谢谢
<Grid x:Name="Layout" >
<TextBox Height="80" Width="340" InputScope="Search" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Image Source="/Assets/pesquisa.png" Height="76" Width="76" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<phone:LongListSelector x:Name="Conteudo" >
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Nome}"/>
<phone:LongListSelector x:Name="cities" ItemsSource="{Binding Alimentos}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding alimentosDoenca}"/>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>