WEB开发网
开发学院图形图像Flash Silverlight(4) - 2.0控件之DataGrid, DatePicker... 阅读

Silverlight(4) - 2.0控件之DataGrid, DatePicker, Grid, GridSplitter, HyperlinkButton, Image

 2008-11-14 11:50:51 来源:WEB开发网   
核心提示:本文源代码下载地址:http://flashview.ddvip.com/2008_11/Silverlight.rar在线DEMOhttp://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html 示例1、DataGrid.xaml<UserContro

本文源代码下载地址:

http://flashview.ddvip.com/2008_11/Silverlight.rar

在线DEMO

http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html

示例

1、DataGrid.xaml

<UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" x:Class="Silverlight20.Control.DataGrid"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel HorizontalAlignment="Left">
    
    <!--
    后台邦定方式,自动生成列
    -->
    <data:DataGrid x:Name="dgrd" AutoGenerateColumns="True"></data:DataGrid>
    
  </StackPanel>
</UserControl>

DataGrid.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
  
namespace Silverlight20.Control
{
  public partial class DataGrid : UserControl
  {
    public DataGrid()
    {
      InitializeComponent();
  
      BindData();
    }
  
    void BindData()
    {
      var source = new Data.SourceData();
  
      // 设置 DataGrid 的数据源
      dgrd.ItemsSource = source.GetData().Take(10);
    }
  }
}

1 2 3 4 5  下一页

Tags:Silverlight 控件 DataGrid

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接