We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Column Header Cell Padding

Thread ID:

Created:

Updated:

Platform:

Replies:

94771 Jun 1,2010 12:07 PM UTC Jun 21,2010 04:58 AM UTC WPF 7
loading
Tags: GridControl
Dean Chalk
Asked On June 1, 2010 12:07 PM UTC

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

Ganesan K [Syncfusion]
Replied On 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

canxss
Replied On 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.

Ganesan K [Syncfusion]
Replied On 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

canxss
Replied On 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.

Ganesan K [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Ganesan K [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;