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

GridView columns from a XAML resource file.

2 Answers 189 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 15 Feb 2010, 07:24 PM
Can RadGridView columns be placed in a ResourceDirectory assigned to the GridViewColumnCollection or does one have to use a control template to accomplish this?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 18 Feb 2010, 01:01 PM
Hello Larry,

I believe the single possible solution is to place a columns collection in your resources like :

<telerik:GridViewColumnCollection x:Key="columns">
    <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}" />
    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" />
</telerik:GridViewColumnCollection>

After that unfortunatelly there is not pure XAML solution. Instead you should do the following in codebehind.

get the resource as GridViewColumnCollection,
add the columns in the GridViewColumnCollection to RadGridView.Columns ( e.g. usng the RadGridView.Columns.AddRange method) .


Greetings,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Larry
Top achievements
Rank 1
answered on 18 Feb 2010, 02:47 PM
Thanks for the reply. It would be very useful though if one could define different column configurations as you demonstrated, then swap them in and out via triggers in XAML. It would then be easy to assign different datasources to the same RadGridView and custom tailor the columns in XAML.

Thanks.
Tags
GridView
Asked by
Larry
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Larry
Top achievements
Rank 1
Share this question
or