ylbtech-SilverLight-Basic-Control:基础控件使用(3)-DataGrid控件 |
DataGrid控件-后台绑定
- 自动生成表列
- 不自动生成表列
1.A,返回顶部Person类(数据源提供者) |
1,
View Code
4,
1.B,返回顶部 DataGrid控件绑定数据源-【AutoGenerateColumns=True】-自动生成表列 |
1,
<data:DataGrid AutoGenerateColumns="True" Height="200" HorizontalAlignment="Left" Margin="108,82,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="200" IsEnabled="True" DataContext="{Binding}" />
2,Name,Height,Width,
AutoGenerateColumns[自动生成表列]=True|False
3,
View Code
4,
1.C,返回顶部DataGrid控件绑定数据源-【AutoGenerateColumns=False】-不自动生成表列 |
1,
<data:DataGrid AutoGenerateColumns="False" Height="200" HorizontalAlignment="Left" Margin="108,82,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="200" IsEnabled="True" DataContext="{Binding}" > <data:DataGrid.Columns> <data:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="编号" Binding="{Binding Id}" IsReadOnly="True" /> <data:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="姓名" Binding="{Binding Name}" /> <data:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="年龄" Binding="{Binding Age}" /> </data:DataGrid.Columns> </data:DataGrid>
2,Name,Height,Width,
AutoGenerateColumns,Header[列头名称],Binding[{Binding 属性名称}],IsReadOnly
3,代码同上 1.B.3
4,
1.D,返回顶部 |
本文转自ylbtech博客园博客,原文链接:http://www.cnblogs.com/ylbtech/p/3398217.html
,如需转载请自行联系原作者