Q:

Link List(Of Structures) to DataGrid

I have the following structure
Public Structure matrixblock
  Public name As String
  Public firstReference As List
  Public secondReference As List
End Structure

I save a bunch of these structures in another list:
dim result as List(of matrixblock)

I would like to bind this list to a DataGrid and in the columns should be:

Column one : name
Column two : firstReference.Count
Column three : secondReference.Count

Can someone help me with setting this up?
Thanks

A:

If you bind the matrixblock structure directly, if any items are added to the internal lists, the bound count properties would not update. You would be better off making this a class, and implement the INotifyPropertyChanged interface, and add two new properties to you class, that represent you the count properties of the list.
However, if you did this, would still need to handle the logic of knowing when the list count had changed, when items are added or removed to the list.  You could make use of ObservableCollections to solve this.
In reality, you should not be binding the structure or class directly anyway, and should make use of the MVVM pattern, and have a ViewModel that exposes the properties you wish to bind to the datagrid.  A quick search on google will point you in the right direction on the MVVM pattern.

