WEB开发网
开发学院图形图像Flash Using The Silverlight DataGrid 阅读

Using The Silverlight DataGrid

 2008-10-24 11:47:00 来源:WEB开发网   
核心提示: It adds an instance of the DataGrid as a child of "LayoutRoot"<data:DataGrid></data:DataGrid>If you are the type of the per

It adds an instance of the DataGrid as a child of "LayoutRoot"<data:DataGrid></data:DataGrid>

If you are the type of the person who likes to see things working after each step, feel free to F5 (choose the option to allow debugging in the popup) and take in the awesome sight that is an empty DataGrid.

Using The Silverlight DataGrid

Not much here, so lets fill it with something.

Step 2: Set the ItemsSource and AutoGenerateColumns

The way to make a DataGrid interesting is by giving it some data. This is done through the DataGrid's ItemsSource property. This is same property that other controls in WPF and Silverlight, such as ListBox, use to specify where they will get their data. The one difference here is that you cannot place arbitrary content in it and have it create a collection for you.

Instead you need to provide it a collection of anything that implements IEnumerable such as a List or ObservableCollection.

The ItemsSource can be specified inline in XAML such as:

<data:DataGrid x:Name="dg">
  <data:DataGrid.ItemsSource>
    <!--Something that implements IEnumerable -->
  </data:DataGrid.ItemsSource>
</data:DataGrid>

However, it is more commonly set in code behind, which is what we will do in this example. 

上一页  1 2 3 4 5 6  下一页

Tags:Using The Silverlight

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接