码迷,mamicode.com
首页 > Windows程序 > 详细

win8开发入门——GridView

时间:2014-11-25 09:15:13      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   使用   sp   文件   数据   on   2014   

网上查到关于GridView的资料大多是如何显示分组数据的,最基本的用法介绍的比较少,这里介绍一下如何使用GridView显示最简单的数据,仅供入门者参考。

添加新项,选择项页。

bubuko.com,布布扣

点是添加文件。

bubuko.com,布布扣

在ItemsPage1.xaml中可以看到<DataTemplate>有三个控件,是一个Image和两个TextBlock,分别绑定的字段为ImagePath,Title和Subtitle。在ItemsPage1.xaml.cs中添加如下新类:

class clsItemSource
{
  public string ImagePath { get; set; }
  public string Title { get; set; }
  public string Subtitle { get; set; }
  public clsItemSource(string ImagePath, string Title, string Subtitle)
  {
    this.ImagePath = ImagePath;
    this.Title = Title;
    this.Subtitle = Subtitle;
  }
}

在navigationHelper_LoadState中添加

ObservableCollection<clsItemSource> lstItemSource = new ObservableCollection<clsItemSource>();
itemGridView.ItemsSource = lstItemSource;
lstItemSource.Add(new clsItemSource("/Asseta/Logo.scale-100.png", "title1", "subtitle1"));
lstItemSource.Add(new clsItemSource("/Asseta/Logo.scale-100.png", "title2", "subtitle2"));

然后在MainPage中添加一个按钮,并导航到该页面

Frame.Navigate(typeof(ItemsPage1));

运行即可。

bubuko.com,布布扣

本文仅介绍了最基本的用法,需使用更复杂的功能可搜索相关资料。

win8开发入门——GridView

标签:blog   http   io   使用   sp   文件   数据   on   2014   

原文地址:http://www.cnblogs.com/lzn1007/p/4120134.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!