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

CellTemplate and binding

1 Answer 248 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jokerwolf
Top achievements
Rank 1
Jokerwolf asked on 11 Aug 2010, 01:02 PM
Hello,
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
0
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.
MainWindow.xaml.cs
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;
           template.Seal();
           col.CellTemplate = template;
MainWindow.xaml
<Window x:Class="RadControlsWpfApp1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadGridView x:Name="radGrid" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="WPF"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>

Regards,
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
Tags
GridView
Asked by
Jokerwolf
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or