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

Setting CellHeaderStyle programmatically doesn't work

2 Answers 75 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.
Matthew Kruczek
Top achievements
Rank 1
Matthew Kruczek asked on 07 May 2012, 06:48 PM
I am building a grid dynamically.  Part of that building is creating each of the columns.  I want to create my own cell header style for my columns which I have done and put into a resource library.

The problem is that when I set this resource programmatically it ignores it...if I do it in XAML it works perfectly.  I am further irritated by the fact that almost all of the examples on the Telerik site do all of the code in XAML and none on the backend.  Could someone please assist me with this?

I have attached a piece of code and picture of it not working...I would have loved to attach a whole project...but apparently I can't do that.

public MainPage()
{
    InitializeComponent();
     
    var foo = new GridViewDataColumn();
    foo.Header = "test";
    foo.DataMemberBinding = new Binding("ContactName");
    foo.HeaderCellStyle = (Style)this.Resources["GridViewHeaderCellStyle"];
    this.DataGrid.Columns.Add(foo);
     
     
         
}














2 Answers, 1 is accepted

Sort by
0
Matthew Kruczek
Top achievements
Rank 1
answered on 07 May 2012, 07:33 PM
NM I figured it out...it was the way I was accessing the resource dictionary
0
Almond
Top achievements
Rank 1
answered on 11 May 2012, 03:23 AM
Hello Matthew,

Coudl you possibly post your solution? I too am in need of the same code.

Thanks in advance.

almond
Tags
GridView
Asked by
Matthew Kruczek
Top achievements
Rank 1
Answers by
Matthew Kruczek
Top achievements
Rank 1
Almond
Top achievements
Rank 1
Share this question
or