This is a migrated thread and some comments may be shown as answers.

[Solved] Binding columns at run time

1 Answer 149 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gil
Top achievements
Rank 1
Gil asked on 25 Mar 2009, 12:53 PM
Hi,

I have a code that uses the standard Silverlight DataGrid and does the following:

In run time, it gets a collection of items.
Each item has a 'name' property and a collection of items (dates with appointments data inside).
Using the code itself, I managed to dynamically create one column for the name property and few columns for each item in the dates collection so that it looks as if it's a flat grid.

The first column presents a simple text (the name)
The other columns presents a user control - which is relevant to the specific date and presents a list of appointments.

The implementation included overriding the DataGridColumn class and overriding the GenerateElement function in order to create the user control and bind it to a specific item in the collection using converters.

I'm looking for ways to implement the same thing with the new GridView.
The samples I saw so far were mostly XAML based, and I'm looking for a way to do it by code.

I need to be able to define in runtime - how many columns will be in the grid, which user controls to place inside and perform the binding to a specific item in the collection.

Thanks in advance.


1 Answer, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 30 Mar 2009, 09:04 AM
Hi Gil,

I have prepared an example that illustrates your scenario. Hope you will find it useful.

Kind regards,
Stefan Dobrev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Gil
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Share this question
or