I've got an ObservableCollection "AnswerPossibilities" that I can successfully bind a ListBox to:
<ListBox ItemsSource="{Binding AnswerPossibilities}" DisplayMemberPath="Text" />
Now, I've followed this to add columns to a DataGrid at runtime, and I'm trying to bind the same ObservableCollection "AnswerPossibilities" to a column:
DataGridTextColumn column = new DataGridTextColumn()
{
Header = "Header 1",
Binding = new System.Windows.Data.Binding("AnswerPossibilities")
};
ColumnCollection.Add(column);
The Grid displays "Header 1", but the "AnswerPossibilities" are missing, the grid is empty.
The XAML for the DataGrid is
<DataGrid Name="dataGrid"
local:DataGridColumnsBehavior.BindableColumns="{Binding ColumnCollection}"
AutoGenerateColumns="False"/>
I've tried adding DisplayMemberPath="Text" to the DataGrid, but that did not change a thing. After half a day with the grid.. I'd be very thankful for any help!