オブジェクトをDataTableに入れて、DataGridのItemsSourceとして使用しようとしています。
foreach (Translate t in item.Translations)
{
if (rowArray[t.IdSprache] == null)
{
rowArray[t.IdSprache] = t; //here I add the Translate objects to the object[]
}
}
dt.Rows.Add(rowArray); //adding the object[] to the DataTable
var test = dt.Rows[cnt].ItemArray[1] as Translate; //aaaaaaaaaaaaaaand the object is gone (test is always null)
cnt++;
}
すべて正常に動作しますが、DataRowの要素をTranslate-Objectsにキャストし直したい場合は、常に。を取得しnull
ます。
行を調べるとItemArray
、オブジェクトはオブジェクトではなく文字列(Assembly.Type
)としてのみ表示されTranslate
ます。
誰かがこれの回避策/解決策を知っていますか?