为什么LongListSelector不显示,绑定的数据也不显示,请高手请教?
xaml代码:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Name="itemTemplate">
<StackPanel>
<TextBlock Text="{Binding Height}"/>
<TextBlockText="{Binding Weight}" />
<TextBlock Text="{Binding Sex}" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="headTemplate">
<StackPanel>
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<Grid x:Name="ContentPanel">
<phone:LongListSelector
Visibility="Visible"
Name="myLongListSelector"
ItemTemplate="{StaticResource itemTemplate}"
GroupHeaderTemplate="{StaticResource headTemplate}"
LayoutMode="List"
IsGroupingEnabled="True"
HideEmptyGroups="True"
/>
cs代码:
public class person
{
public string Name { get; set; }
public string Height { get; set; }
public string Weight { get; set; }
public string Sex { get; set; }
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
List<person> list = new List<person>();
list.Add(new person() {Name="sdf",Height="23",Weight="34",Sex="nan" });
list.Add(new person() { Name = "aa", Height = "11", Weight = "22", Sex = "nan" });
list.Add(new person() { Name = "ss", Height = "22", Weight = "43", Sex = "nv" });
list.Add(new person() { Name = "dd", Height = "44", Weight = "56", Sex = "nan" });
list.Add(new person() { Name = "ff", Height = "55", Weight = "65", Sex = "nv" });
list.Add(new person() { Name = "dd", Height = "66", Weight = "87", Sex = "nan" });
myLongListSelector.ItemsSource = list;
}