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. Image for the cookie policy date
close icon

Setting Default Row Height through XAML (NOT CODE)

I would like to be able to set default row height and default column header height through XAML, not code.
I know in code you can use something like this:
this.grid.Model.RowHeights.DefaultLineSize = 20d; //row height


7 Replies

GK Ganesan K Syncfusion Team May 20, 2010 04:21 AM UTC

Hi Andre,

Setting DefaultLineSize via Xaml is not possible, but we can acheive this by using attached property.

1.Create the attached property as follows.

[C#]

public static readonly DependencyProperty RowHeightProperty = DependencyProperty.RegisterAttached(
"RowHeight", typeof(double), typeof(A) ,new FrameworkPropertyMetadata(32.0, OnRowHeightsChanged));

2.Set this property in the xaml like below.

[Xaml]

x:Name="dataGrid"
AutoPopulateColumns="True"
AutoPopulateRelations="False"
local:A.RowHeight="200">

3.Use the following code in OnRowHeightsChanged.

[C#]
var datagrid = d as GridDataControl;
datagrid.Model.RowHeights.DefaultLineSize =(double) args.NewValue ;

Download the workarond sample under the following location.

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

Please let us know if you need any more details.

Thanks
Ganesan


AS Andre Slenko May 20, 2010 12:25 PM UTC

Thank you for your response.
It seems to me that this property is such an essential part of the grid control, that there should NOT be any need for workarounds, it must be incorporated in the grid XAML. It would be nice to see this implemented in the future versions.
How do you set the height of the column header row?


GK Ganesan K Syncfusion Team May 21, 2010 08:52 AM UTC

Hi Andre,

Thanks for your feedback. We have forwarded the request to our development team to include this property in our future versions.

You can use the following code to set height of the column header row.

datagrid.Model.RowHeights[0] = 30;

Please let us know if you need any further details.

Thanks
Ganesan


AS Andre Slenko May 24, 2010 09:18 PM UTC

Thanks, that worked!


VP Varun P Syncfusion Team May 25, 2010 10:12 AM UTC

Hi Andre,

We are glad that it worked on your side.

Please let me know if you have any queries.

Thanks,
Varun


AJ Abhishek Joshi February 11, 2011 07:09 AM UTC

Hi,

Is this property available in the latest 9.1 release? It looks a lot of unnecessary work just for setting row height!!

Thanks,
Abhishek



RA Rajasekar Syncfusion Team February 17, 2011 10:31 AM UTC

Hi Abhishek,

Thanks for your update.

In current version(v9.1.0.20) we don’t have support for setting the row height in XAML. In code behind you can set the row height as stated above, but if you want set in XAML means you can set through Attached property.

Please let us know if you have any queries.

Thanks,
Rajasekar



Loader.
Live Chat Icon For mobile
Up arrow icon