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/
    关于作者:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    轻松搭建CAS 5.x系列(7)-在CAS Server使用第三方帐号做认证
    轻松搭建CAS 5.x系列(6)-在CAS Server上增加OAuth2.0协议
    轻松搭建CAS 5.x系列(5)-增加密码找回和密码修改功能
    CAS 5.x搭建常见问题系列(3).Failure to find org.apereo.cas:cas-server-support-pm-jdbc:jar:5.1.9
    CAS 5.x搭建常见问题系列(2).PKIX path building failed
    CAS 5.x搭建常见问题系列(1).未认证的授权服务
    轻松搭建CAS 5.x系列(4)-Java客户端程序接入CAS单点登录,Hello World版
    轻松搭建CAS 5.x系列文章
    CAS实现SSO单点登录-CAS Server 5.3搭建 cas5.3搭建 cas5.3去除https cas 去除https cas 5.x 去除https
    互联网大咖都要收藏的几个网站,纯干货
  • 原文地址:https://www.cnblogs.com/facingwaller/p/1755567.html
Copyright © 2011-2022 走看看