Slow and Steady Silverlight (4)

Source: Internet
Author: User

Slow and Steady Silverlight (4)-2.0 control Datagrid,datepicker,grid,gridsplitter,hyperlinkbutton,image

Online Demo

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

Example

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);
    }
  }
}

2, Datepicker.xaml

<UserControl x:Class="Silverlight20.Control.DatePicker"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls">
  <StackPanel HorizontalAlignment="Left">

    <!--
    TextBox 结合 Calendar,经典的选择日期的方式
    SelectedDateFormat - 被选中的日期的显示格式 [System.Windows.Controls.DatePickerFormat枚举]
      SelectedDateFormat.Short - 简短格式。默认值。如2008-10-10
      SelectedDateFormat.Long - 非简短格式。如2008年10月10日
    -->
    <basics:DatePicker Width="200" SelectedDateFormat="Short"></basics:DatePicker>

  </StackPanel>
</UserControl>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.