日期:2014-05-17 浏览次数:21036 次
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid CellEditEnding="dataGrid1_CellEditEnding" AutoGenerateColumns="False" Height="198" HorizontalAlignment="Left" Margin="50,41,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="377">
<DataGrid.Columns>
<DataGridTextColumn Header="选择" Binding="{Binding Count}" Width="100" />
</DataGrid.Columns>
</DataGrid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="308,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
dataGrid1.ItemsSource = new number[]
{
new number(){ Count = "1" },
new number(){ Count = "2" },
new number(){ Count = "3" },
new number(){ Count = "4" },
new number(){ Count = "4" }