Silverlight DataGrid用法
一、數據綁定
1、整個datagrid綁定數據源
PagedCollectionView drugListview = new PagedCollectionView(mClient.Students);
//一定要用PagedCollectionView
DataGridbyPager.ItemsSource = null;
DataGridbyPager.ItemsSource = drugListview;//綁定數據源
2、數據列綁定數據源
單個列
<sdk:DataGridTextColumn Header="收貨人" Width="100" Binding="{Binding SNAME}"></sdk:DataGridTextColumn>
自定義列
<sdk:DataGridTemplateColumn Width="440" Header="地址">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel VerticalAlignment="Center" Orientation ="Horizontal">
<TextBlock Text="{Binding PROVIENCE}" ></TextBlock>
<TextBlock Text="{Binding CITY}" ></TextBlock>
<TextBlock Text="{Binding AREA}" ></TextBlock>
<TextBlock Text="{Binding DETAIL_ADDRESS}" ></TextBlock>
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>