zoukankan      html  css  js  c++  java
  • Silverlight学习笔记第一季(1)DataGrid

    写在前面的话,本系列是本人的笔记。

    1只是一个索引,很多可能都不会有很多具体的内容。

    2有新的体会或者技巧,资源的话,我会来更新。并用日期注明

    DataGrid  (用于 Silverlight 的 .NET Framework 类库)

    //(what)

    datagrid 有什么用?

    @1绑定数据。如果你需要你的数据编辑后可以更新你的数据源。

    需要实现INotifyCollectionChanged接口。 

    @2 两种定义 显示数据的 方法

         1 使用 AutoGeneratingColumn 自动生成,一般来说不够灵活,其实一般的要求也可以达到

              { 自定义行头的解决办法:

                     @1数据 使用 displayname  

                     @2自定义 AutoGeneratingColumn="dataGrid1_AutoGeneratingColumn"

    代码
    // Replace the DueDate column with a custom template column.
    if (e.PropertyName == "DueDate")
    {
    // Create a new template column.
    DataGridTemplateColumn templateColumn = new DataGridTemplateColumn();
    templateColumn.Header
    = "Due Date";
    templateColumn.CellTemplate
    = (DataTemplate)Resources["dueDateCellTemplate"];
    templateColumn.CellEditingTemplate
    = (DataTemplate)Resources["dueDateCellEditingTemplate"];
    templateColumn.SortMemberPath
    = "DueDate";
    // ...

               }

         2  xaml中定义模板。这个比较泛滥。

    @3分组、排序和筛选

    使用 PagedCollectionView。 

     

     

     

    代码
    //排序
    if (pagedCollectionView.CanSort)
    {
    pagedCollectionView.SortDescriptions.Add(
    new SortDescription("Sequence", ListSortDirection.Ascending));
    }
    //分组
    if (pagedCollectionView.CanGroup)
    {
    var pgd1
    = new PropertyGroupDescription("Sequence");
    pagedCollectionView.GroupDescriptions.Add(pgd1);
    pagedCollectionView.GroupDescriptions.Remove(pgd1);
    // pagedCollectionView.GroupDescriptions.Add(pgd1);

    }
    //过滤
    if (pagedCollectionView.CanFilter)
    {
    Predicate
    <object> predicate = new Predicate<object>(FilterCompletedTasks);
    pagedCollectionView.Filter
    += predicate;
    }

    //过滤
    public bool FilterCompletedTasks(object t)
    {
    KF_Section task
    = t as KF_Section;
    return (task.Display == 1);//保留DISPLAY属性是1的
    }

    @4编辑

    @5验证

    在datagrid上面验证

    @6分页

    与datapager控件结合

      pagedCollectionView.PageSize = 5;

    dG_test.ItemsSource = pagedCollectionView;
    dataPager1.Source
    = pagedCollectionView;


    资源索引:

    MSDN中的资源点我进入

    以下是目录

    如何:向页中添加 DataGrid 控件

    如何在 DataGrid 控件中显示和配置行详细信息
    如何:自定义 DataGrid 控件中自动生成的列
    如何对 DataGrid 控件中的数据进行分组、排序和筛选
    演练:使用属性自定义 DataGrid 控件
    DataGrid 控件中的调整大小选项

    DataGrid 控件中的默认键盘和鼠标行为

    如何在 DataGrid 控件中显示和配置行详细信息

    如何:自定义 DataGrid 控件中自动生成的列

    如何对 DataGrid 控件中的数据进行分组、排序和筛选

    演练:使用属性自定义 DataGrid 控件DataGrid 控件中的

    调整大小选项DataGrid 控件中的调整大小选项

    2 Silverlight控件应用系列索引 代码贴的多啊。。。看起来有点乱。

      图(没有过滤了)

    ------------------------------------------------------------------------------------------------------------

    2010-6-10   

    ------------------------------------------------------------------------------------------------------------

      pagedCollectionView.PageSize = 5

    应该在绑定数据源之后执行才有效。

    资源 

    模板样式和类型

    http://msdn.microsoft.com/zh-cn/library/cc278066(v=VS.95).aspx

    ------------------------------------------------------------------------------------------------------------

    2010-6-10    updata13:46

    ------------------------------------------------------------------------------------------------------------

    http://silverlightchina.net/html/zhuantixilie/getstart/2010/0409/978.html


    作者:撞破南墙
    出处:http://www.cnblogs.com/facingwaller/
    关于作者:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    sfs2x 连接 mongodb
    java websocket
    webstorm 4.0 注册码
    解决 sfs2 admin tool 找不到扩展
    window 注册表五大类
    opengl 学习第二日
    java google Protobuf
    扩展 java sencha touch PhonegapPlugin
    sencha touch2 kryonet socket phonegap 通信 作者:围城
    sencha touch2 layout 笔记
  • 原文地址:https://www.cnblogs.com/facingwaller/p/1755567.html
Copyright © 2011-2022 走看看