WP7之LongListSelector控件
2012-07-12 15:57
183 查看
1.引用:
2.xaml:
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="48"
Margin="8,0,0,0"
Foreground="White"
VerticalAlignment="Bottom"/>
Padding="8,0,0,0" Width="62" Height="62"
HorizontalAlignment="Left">
Foreground="#FFFFFF"
FontSize="48"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"/>
3.后台cs代码
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
LongList.SelectionChanged += new SelectionChangedEventHandler(LongList_SelectionChanged);
}
void LongList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LongList.SelectedItem != null)
{
var d = LongList.SelectedItem as mydata;
if (d != null)
{
}
}
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
List> dt = new List>();
for (int i = 0; i < 10; i++)
{
dt.Add(new Group(i.ToString(), getContent(i)));
}
LongList.ItemsSource = dt;
}
IEnumerable getContent(int k)
{
List dt = new List();
for (int i = 0; i < 10; i++)
{
dt.Add(new mydata() { Name = i.ToString() + "key", Content = i.ToString() + "val" });
}
return dt;
}
}
public class Group : IEnumerable
{
public Group(S groupItem, IEnumerable items)
{
this.GroupItem = groupItem;
this.Items = new List(items);
}
public override bool Equals(object obj)
{
Group other = obj as Group;
return (other != null) && (GroupItem.Equals(other.GroupItem));
}
public override int GetHashCode()
{
return GroupItem.GetHashCode();
}
public S GroupItem { get; set; }
public IList Items { get; set; }
public IEnumerator GetEnumerator()
{
return Items.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return Items.GetEnumerator();
}
}
public class mydata
{
public string Name { get; set; }
public string Content { get; set; }
}
2.xaml:
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="48"
Margin="8,0,0,0"
Foreground="White"
VerticalAlignment="Bottom"/>
Padding="8,0,0,0" Width="62" Height="62"
HorizontalAlignment="Left">
Foreground="#FFFFFF"
FontSize="48"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"/>
3.后台cs代码
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
Loaded += new RoutedEventHandler(MainPage_Loaded);
LongList.SelectionChanged += new SelectionChangedEventHandler(LongList_SelectionChanged);
}
void LongList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (LongList.SelectedItem != null)
{
var d = LongList.SelectedItem as mydata;
if (d != null)
{
}
}
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
List> dt = new List>();
for (int i = 0; i < 10; i++)
{
dt.Add(new Group(i.ToString(), getContent(i)));
}
LongList.ItemsSource = dt;
}
IEnumerable getContent(int k)
{
List dt = new List();
for (int i = 0; i < 10; i++)
{
dt.Add(new mydata() { Name = i.ToString() + "key", Content = i.ToString() + "val" });
}
return dt;
}
}
public class Group : IEnumerable
{
public Group(S groupItem, IEnumerable items)
{
this.GroupItem = groupItem;
this.Items = new List(items);
}
public override bool Equals(object obj)
{
Group other = obj as Group;
return (other != null) && (GroupItem.Equals(other.GroupItem));
}
public override int GetHashCode()
{
return GroupItem.GetHashCode();
}
public S GroupItem { get; set; }
public IList Items { get; set; }
public IEnumerator GetEnumerator()
{
return Items.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return Items.GetEnumerator();
}
}
public class mydata
{
public string Name { get; set; }
public string Content { get; set; }
}
相关文章推荐
- WP7之LongListSelector控件
- LongListSelector 控件 在 wp7 和wp8中的不同之处
- WP7之LongListSelector控件
- 【WP7】一个便捷而且比较炫的分组聚类控件:LongListSelector控件的使用
- WP7中代码设置ListBox和LongListSelector条目项的显示位置
- WP7 LongListSelector in depth | Part1: Visual structure and API
- WP7 Toolkit LoopingSelector 控件 介绍
- Windows Phone 7 LongListSelector控件实现分类列表和字母索引
- 与众不同 windows phone (34) - 8.0 新的控件: LongListSelector
- WP7 LongListSelector in depth | Part2: Data binding scenarios
- WP LongListMultiSelector控件Bug,单项删除第五个时候报错
- 【WP8】简单介绍wp8中原生LongListSelector控件的用法
- window phone7.1 天气预报教程(四)ApplicationBar的设置与LongListSelector控件的使用
- Windows Phone 7 LongListSelector控件实现分类列表和字母索引
- 与众不同 windows phone (34) - 8.0 新的控件: LongListSelector
- Windows Phone 7 LongListSelector控件实现分类列表和字母索引
- Wp8—LongListSelector控件使用
- 【WP8】简单介绍wp8中原生LongListSelector控件的用法
- Windows Phone 7 LongListSelector控件实现分类列表和字母索引
- Wp8—LongListSelector控件使用