【发布时间】:2013-12-17 16:08:59
【问题描述】:
我正在尝试使用 longlistselector 控件来显示人员和他们可能拥有的孩子的列表。有些可能有 1 个孩子,有些可能有更多。
我正在尝试使用 ItemTemplate
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="KidsTemplate">
<StackPanel Grid.Column="1" VerticalAlignment="Top">
<TextBlock Text="{Binding KidsName}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ListTemplate">
<StackPanel Grid.Column="1" VerticalAlignment="Top">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Address}"/>
<ListBox x:Name="PersonKids"
ItemTemplate="{StaticResource KidsTemplate}">
</ListBox>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:LongListSelector x:Name="MultiList"
ItemsSource="{Binding Person}"
ItemTemplate="{StaticResource ListTemplate}">
</phone:LongListSelector>
</Grid>
</Grid>
尝试使用以下类
public class PersonDetail
{
public string Name { get; set; }
public string Address { get; set; }
public Kids PersonKids { get; set; }
}
public class Kids
{
public string KidsName { get; set; }
}
任何帮助都会很棒。
【问题讨论】:
-
你可以使用itemscontrol
标签: c# windows-phone-8 longlistselector