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

CellTemplate and binding

1 Answer 212 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Jokerwolf asked on 11 Aug 2010, 01:02 PM
I've got another problem today. Is it posible to send column header text as a ConverterPerameter for CellTemplate?

1 Answer, 1 is accepted

Sort by
Vanya Pavlova
Telerik team
answered on 13 Aug 2010, 03:51 PM
Hello Jokerwolf,

Yes that is possible,I would advise you to create the Cell Template of  your particular column in code behind and after that pass the column header as converter parameter in the generated converter,the skeleton of your code,you should write only the Converter Parameter.
radGrid.ItemsSource=(from c in Enumerable.Range(0,10) select  c).ToList();
           FrameworkElementFactory factory = new FrameworkElementFactory(typeof(TextBlock));
           var col=radGrid.Columns[0];
           Binding b=new Binding("Header");
           b.Source = col;
           factory.SetBinding(TextBlock.TextProperty, b);
           DataTemplate template = new DataTemplate();
           template.VisualTree = factory;
           col.CellTemplate = template;
<Window x:Class="RadControlsWpfApp1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <telerik:RadGridView x:Name="radGrid" AutoGenerateColumns="False">
                <telerik:GridViewDataColumn Header="WPF"/>

Vanya Pavlova
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
Asked by
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question