'How can I use List(Of <T>) as MethodParameters in ObjectDataProvider? (WPF)
I have an Object 'ArticleMasterData' and a list with instances of this Object. To show it in the XamDataGrid I have to convert it to a DataTable, which i do with 'ListToDataTable'. First off the VB Code for it:
Private Function ListToDataTable(Of T)(ByVal AccessDataList As IList(Of T)) As DataTable
Dim table As New DataTable
Dim fields() As FieldInfo = GetType(T).GetFields
For Each field As FieldInfo In fields
table.Columns.Add(field.Name, field.FieldType)
Next
For Each item As T In AccessDataList
Dim row As DataRow = table.NewRow
For Each field As FieldInfo In fields
row(field.Name) = field.GetValue(item)
Next
table.Rows.Add(row)
Next
Return table
End Function
I need now the list(Of ArticleMasterData) as MethodParamter:
<Window.Resources>
<ObjectDataProvider x:Key="odpImport"
ObjectType="{x:Type local:ArticleMasterData}"
MethodName="ListToDataTable"
>
<ObjectDataProvider.MethodParameters>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
How can I do this? I didn't find anything in the Documentation or on google, so I appreciate any help! Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
