WPFToolkit and how to set the columns at design time

WPFToolkit and how to set the columns at design time

Old forum URL: forums.lhotka.net/forums/t/5839.aspx


GeorgeG posted on Thursday, November 20, 2008

I have an Orders object trying to setup the columns in the datagrid. I can see  all the columns at run time. However, at design time I am getting "You need to set ItemsSource.." while trying to go to add/edit columns in the datagrid designer. This is what I am using

<csla:CslaDataProvider x:Key="Orders"

ObjectType="{x:Type business:Orders}"

FactoryMethod="GetOrders"

IsAsynchronous="False"

IsInitialLoadEnabled="False"

ManageObjectLifetime="True"/>

 

<grdOrders:DataGrid Grid.Row="1" Margin="0,34,6,7"

Name="dataGridOrders"

xmlns:grdOrders="http://schemas.microsoft.com/wpf/2008/toolkit"

AutoGenerateColumns="False"

ItemsSource="{Binding Source={StaticResource Orders}}"

EnableColumnVirtualization="True"

AlternatingRowBackground="LightGray" />

What am I missing to select the columns that I need from the DataGrid  add/edit columns designer?

Thanks

 

sergeyb replied on Thursday, November 20, 2008

Assuming this grid is similar to SL grid, you need to add columns to the grid.  I am not certain the designer supports it, so you can do so manually in XAML.

 

<grdOrders:DataGrid.Columns><… 

 

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: GeorgeG [mailto:cslanet@lhotka.net]
Sent: Thursday, November 20, 2008 3:47 PM
To: Sergey Barskiy
Subject: [CSLA .NET] WPFToolkit and how to set the columns at design time

 

I have an Orders object trying to setup the columns in the datagrid. I can see  all the columns at run time. However, at design time I am getting "You need to set ItemsSource.." while trying to go to add/edit columns in the datagrid designer. This is what I am using

<csla:CslaDataProvider x:Key="Orders"

ObjectType="{x:Type business:Orders}"

FactoryMethod="GetOrders"

IsAsynchronous="False"

IsInitialLoadEnabled="False"

ManageObjectLifetime="True"/>

 

<grdOrders:DataGrid Grid.Row="1" Margin="0,34,6,7"

Name="dataGridOrders"

xmlns:grdOrders="http://schemas.microsoft.com/wpf/2008/toolkit"

AutoGenerateColumns="False"

ItemsSource="{Binding Source={StaticResource Orders}}"

EnableColumnVirtualization="True"

AlternatingRowBackground="LightGray" />

What am I missing to select the columns that I need from the DataGrid  add/edit columns designer?

Thanks

 



GeorgeG replied on Thursday, November 20, 2008

Setting the column manually does work. This is sample code for just one column.

<dataGrid:DataGrid Grid.Row="1" Margin="0,34,6,7"

Name="dataGridOrders"

AutoGenerateColumns="False"

ItemsSource="{Binding Source={StaticResource Orders}}"

dataGrid:DataGrid.Columns>

<dataGrid:DataGridTextColumn Binding="{Binding Path=Cust_code}"

Header="CustCode"

IsReadOnly="True"/>

</dataGrid:DataGrid.Columns>

</dataGrid:DataGrid >

Thanks

 

Copyright (c) Marimer LLC