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
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