Herman
Well-known member
I have this type:
And I have a Linq query that returns an IEnumerable(Of cTechSupportCall). Now I want to bind the result of that query to a WPF DataGrid. Here is the XAML for the DataGrid:
When I try to bind the results of the query to the DataGrid any of the following ways:
... and then call MyGrid.UpdateLayout(), the resulting grid looks like this:
The rows of data are correctly bound, but the columns are not generated, and for the life of me I cannot figure out why... Is it the nullable DateTime that is causing this issue? This is really frustrating, because I clearly remember having no issue at all binding a datatable to a DataGrid before. Does it just not like custom types?
Public Class cTechSupportCall Public CallId As String Public CustomerName As String Public CallbackLimit As DateTime? Public StartTime As DateTime? Public StopTime As DateTime? Public LastModOn As DateTime? Public LastModBy As String Public Owner As String Public Duration As Double End Class
And I have a Linq query that returns an IEnumerable(Of cTechSupportCall). Now I want to bind the result of that query to a WPF DataGrid. Here is the XAML for the DataGrid:
VB.NET:
<DataGrid x:Name="MyGrid" AutoGenerateColumns="True" Grid.Row="0" Margin="0" Background="White" AlternatingRowBackground="WhiteSmoke" />
When I try to bind the results of the query to the DataGrid any of the following ways:
MyGrid.ItemsSource = queryResult MyGrid.ItemsSource = queryResult.ToList MyGrid.ItemsSource = New ObservableCollection(Of cTechSupportCall)(queryResult)
... and then call MyGrid.UpdateLayout(), the resulting grid looks like this:
The rows of data are correctly bound, but the columns are not generated, and for the life of me I cannot figure out why... Is it the nullable DateTime that is causing this issue? This is really frustrating, because I clearly remember having no issue at all binding a datatable to a DataGrid before. Does it just not like custom types?