Grid Column Header Cell Padding

Hi

I'm working on the GridDataControl and have a very simple grid. However, the column header cells have too much padding around the header text, and I want to reduce this.

I cant seem to find a way to modify the header cells style

Thanks

Dean

7 Replies

GK Ganesan K Syncfusion Team June 4, 2010 05:04 AM UTC

Hi Dean,

Thanks for using Syncfusion products.

You can use HeaderStyle property to achieve this requirement,

Sample code snippets:







Please let us know if you need any more details.

Thanks
Ganesan


CA canxss June 6, 2010 06:14 PM UTC

But how can we define a style including the above properties to apply to the HeaderStyle property of the GridDataVisibleColumn?

I don't want to rewrite the same common style for all the headers.


GK Ganesan K Syncfusion Team June 9, 2010 05:54 AM UTC

Hi,

You can use the following code,

this.dataGrid.Model.HeaderStyle.Padding = new CellMarginsInfo(5);
this.dataGrid.Model.HeaderStyle.BorderMargins = new CellMarginsInfo(5);

Please let us know if you need any more details.

Thanks
Ganesan


CA canxss June 9, 2010 09:20 AM UTC

Thanks for the reply.

But is there any way to do this in XAML by using styles? I don't want to manage my UI through code-behind. And also I'm using DataTemplates to render my views therefore it's even cumbersome for me to obtain a reference to the GridDataControl in the DataTemplate.


GK Ganesan K Syncfusion Team June 15, 2010 05:45 AM UTC

Hi ,

Thanks for the update.

Setting HeaderStyle through Xaml is not possible, but you can use the “attached” property to acheive this.

1.Create the attached property as follows :

[C#]

public static readonly DependencyProperty PaddingProperty = DependencyProperty.RegisterAttached(
"Padding", typeof(int), typeof(A) ,new FrameworkPropertyMetadata(0, OnPaddingsChanged));

2.Set this property in the xaml as follows.

[Xaml]

x:Name="dataGrid"
AutoPopulateColumns="True"
AutoPopulateRelations="False"
local:A.Padding="5">

3.Use the following code in OnPaddingsChanged event.

[C#]
var datagrid = d as GridDataControl;
int value = (int) args.NewValue
this.dataGrid.Model.HeaderStyle.Padding = new CellMarginsInfo(value);

Please let us know if you need any further details.

Thanks
Ganesan


AD Administrator Syncfusion Team June 16, 2010 02:43 PM UTC

Is the followinf still valid XAML for the GridDataControl as i get the following during compile:

System.Windows.Markup.XamlParseException occurred
Message="Cannot convert string '2' in attribute 'BorderMargins' to object of type 'Syncfusion.Windows.Controls.Cells.CellMarginsInfo'. StyleInfoBaseConverter cannot convert from System.String. Error at object 'Syncfusion.Windows.Controls.Grid.GridDataColumnStyle'


Thanks


GK Ganesan K Syncfusion Team June 21, 2010 04:58 AM UTC

Hi Paul,

Could you please check the following sample.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GDCAttachedProperty-1110427261.zip

Let us know if you need any more details.

Thanks
Ganesan

Loader.
Up arrow icon