Datagrid template for listbox and textbox

< UserControl  x:Class ="SilverlightApplication3.MainPage"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable
="d"
    d:DesignHeight
="300"  d:DesignWidth ="400"  xmlns:sdk ="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" >

     < StackPanel >
         < Button  Content ="Button"  Height ="23"  HorizontalAlignment ="Left"  Name ="button1"  VerticalAlignment ="Top"  Width ="75"  Click ="button1_Click"   />
         < sdk:DataGrid  x:Name ="data"  AutoGenerateColumns ="False"  Height ="168"  HorizontalAlignment ="Left"  Margin ="0,27,0,0"  VerticalAlignment ="Top"  Width ="317" >
             < sdk:DataGrid.Columns >
                 < sdk:DataGridTextColumn  Header ="Name"  Binding ="{Binding Name}" />
                 < sdk:DataGridTemplateColumn  Header ="Firend" >
                     < sdk:DataGridTemplateColumn.CellTemplate >
                         < DataTemplate >
                             < ComboBox  ItemsSource ="{Binding Firends}"  DisplayMemberPath ="Name"  SelectedIndex ="0" />
                         </ DataTemplate >
                     </ sdk:DataGridTemplateColumn.CellTemplate >
                 </ sdk:DataGridTemplateColumn >
                 < sdk:DataGridTemplateColumn  Header ="Age" >
                     < sdk:DataGridTemplateColumn.CellTemplate >
                         < DataTemplate >
                             < TextBox  Text ="{Binding Age}"  Width ="100" />
                         </ DataTemplate >
                     </ sdk:DataGridTemplateColumn.CellTemplate >
                 </ sdk:DataGridTemplateColumn >
             </ sdk:DataGrid.Columns >
         </ sdk:DataGrid >
     </ StackPanel >
</ UserControl >

你可能感兴趣的:(datagrid)