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

Setting GridViewCell background and HorizontalAlignment

1 Answer 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ivano
Top achievements
Rank 1
Ivano asked on 21 Jul 2010, 07:59 PM
I'm trying to set both background an HorizontalAlignment on GridViewCells of a GridViewDataColumn at run time as follows:

Binding backgroundBinding = new Binding("Item.Format[" + column.UniqueName + "].Background");
Binding horizontalAlignmentBinding  = new Binding("Item.Format[" + column.UniqueName + "].HorizontalAlignment");

Style cellStyle = new Style(typeof(GridViewCell));
cellStyle.Setters.Add(new Setter(GridViewCell.BackgroundProperty, backgroundBinding));
cellStyle.Setters.Add(new Setter(GridViewCell.HorizontalAlignmentProperty, horizontalAlignmentBinding));
column.CellStyle = cellStyle

It works;  the point is that background color do not fill whole cell area but only a around cell content (see attached picture).
Same issue for VerticalAlignment.

Sincerely
Ivano

1 Answer, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 22 Jul 2010, 07:06 AM
Hi Ivano,

I guess you should leave HorizontalAlignment to Stretch and bind the HorizontalContentAlignment to be able to control the alignment of the data that is shown within a cell. 


Sincerely yours,
Milan
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
Ivano
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or