当前位置:编程学习 > wap >>

为什么LongListSelector不显示,绑定的数据也不显示,请高手请教?

xaml代码:

 <phone:PhoneApplicationPage.Resources>    

    <DataTemplate x:Name="itemTemplate">      

      <Border BorderBrush="Red" BorderThickness="5">   

              <StackPanel>              

       <TextBlock Foreground="Red" FontSize="46" Text="{Binding Height}" HorizontalAlignment="Stretch"/>    

<TextBlock Foreground="Red" FontSize="46" Text="{Binding Weight}" HorizontalAlignment="Stretch"/>           

  <TextBlock Foreground="Red" FontSize="46" Text="{Binding Sex}" HorizontalAlignment="Stretch"/>      

           </StackPanel>          

   </Border>        

</DataTemplate>      

   <DataTemplate x:Name="headTemplate">   

          <Border BorderBrush="Green" BorderThickness="5">                 <StackPanel>               

      <TextBlock Foreground="Red" FontSize="46" Text="{Binding Name}" HorizontalAlignment="Stretch"/>       

          </StackPanel>    

         </Border>    

     </DataTemplate>  

   </phone:PhoneApplicationPage.Resources>

 

 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" });
            list.Add(new person() { Name = "kjk", Height = "77", Weight = "31", Sex = "nv" });
            list.Add(new person() { Name = "ffd", Height = "88", Weight = "13", Sex = "nan" });
            myLongListSelector.ItemsSource = list;
        }
windows phone 8 --------------------编程问答-------------------- 看看这例子吧http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj244365(v=vs.105).aspx --------------------编程问答-------------------- 怎么没在xaml里看到LongListSelector? --------------------编程问答--------------------  LongListSelector控件在这里,请问为什么不显示?

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <phone:LongListSelector 
                Visibility="Visible"  
                Name="myLongListSelector"
                ItemTemplate="{StaticResource itemTemplate}"
                GroupHeaderTemplate="{StaticResource headTemplate}"
                LayoutMode="List"
                HorizontalAlignment="Left" 
                Height="593"
                VerticalAlignment="Top"
                Width="446" 
                IsGroupingEnabled="True"
                HideEmptyGroups="True"
                /> 
补充:移动开发 ,  Windows Phone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,