Unable to display data in a WPF datagrid that has a DataView instance as the items source

Posted by Jimmy W on Stack Overflow See other posts from Stack Overflow or by Jimmy W
Published on 2010-05-24T14:49:32Z Indexed on 2010/05/24 14:51 UTC
Read the original article Hit count: 435

Filed under:
|
|
|
|

I am using a DataGrid object from the WPF toolkit. I am binding the DataGrid object to the default view of a DataTable instance as declared in the following code:

WeatherGrid.ItemsSource = weatherDataTable.DefaultView;

weatherDataTable has three columns. The first column is defined to contain a string data type. The other two columns are defined to contain double data types. When the application exits the function that calls the binding as expressed in the declaration, The DataGrid object displays data for the first column, but not the other columns. When I type the following in the immediate window in the debugger:

((DataRowView)WeatherGrid.Items[0]).Row[1]

I get a number, but this doesn't correspond with what is being displayed. Why is only the first column visible, and how can I get all of the data to be visible? I'll leave my XAML definition for the DataGrid object below:

<toolkit:DataGrid Margin="12.726,77.71,12,0" Name="WeatherGrid" Height="500" Grid.Row="1" VerticalAlignment="Top" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" />

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf