Land Rovers, .Net en meer!
Berichten tagged DataGrid
Binding a WPF DataGridColumn to a LINQ result
26 aug
I’ve been tinkering with Visual Studio 2010 Beta1 and the .Net 4 framework. One of the things that I’ve tried is filling a DataGrid with the results of a LINQ query. Consider the following code: C#
var voyages = from voyage in entities.Voyage
select new { Number = voyage.Number, ETA = voyage.StartTime };
dataGridTest.ItemsSource = voyages;
XAML
<DataGrid Name="dataGridTest">
<DataGrid.Columns>
<DataGridTextColumn Header="Number" Binding="{Binding Path=Number}" />
<DataGridTextColumn Header="ETA" Binding="{Binding Path=ETA}" />
</DataGrid.Columns>
</DataGrid>
Seems straightforward enough, doesn’t it? Well it does but when you try to run it, it’ll crash and burn with the following exception:
InvalidOperationException: A TwoWay or OneWayToSource binding cannot Meer >