---
title: "C# XAML How to modify the dimensions of the rows and the columns of a Grid"  
description: "C# XAML How to modify the dimensions of the rows and the columns of a Grid"  
author: "Anonymous User"  
published: 2013-12-23  
updated: 2013-12-23  
canonical: https://www.mindstick.com/forum/1834/c-sharp-xaml-how-to-modify-the-dimensions-of-the-rows-and-the-columns-of-a-grid  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# C# XAML How to modify the dimensions of the rows and the columns of a Grid

I have the next [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) in XAML :

```
   
<Grid.RowDefinitions>       
<RowDefinition Height="6*" />       
<RowDefinition Height="*" />   
</Grid.RowDefinitions>
```

What I want is to modify the code in C#. I'm using the next code :

```
 ListBoxGrid.RowDefinitions[0].Height = new GridLength(100); ListBoxGrid.RowDefinitions[1].Height = new GridLength(800);
```

Using pixels to set the Height of the rows works just fine, but I would very much like to use the "*"-thing, something like

```
 ListBoxGrid.RowDefinitions[0].Height = "*"; ListBoxGrid.RowDefinitions[1].Height = "3*";
```

How can I do something like that ? I'm [thinking](https://www.mindstick.com/blog/11889/how-to-change-your-thinking-paradigm) that a solution would be to get the Height of the [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control)/[page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) that contains my [grid](https://www.mindstick.com/forum/369/how-can-i-add-a-column-name-to-my-grid) and make :

```
 ListBoxGrid.RowDefinitions[0].Height =ControlHeight/4; ListBoxGrid.RowDefinitions[1].Height =ControlHeight/4*3;
```

Is there another solution ? More elegant than these [operations](https://www.mindstick.com/blog/304985/how-does-devops-bridge-the-gap-between-development-and-operations-teams-like-git) ? (I will use more than two rows, so it would be nice to not have something very complicated).

## Replies

### Reply by Pravesh Singh

Hi Samuel,\

You can do it, check the other constructors for GridLength

myGrid.RowDefinitions[0].Height = new GridLength(1, GridUnitType.Star);


---

Original Source: https://www.mindstick.com/forum/1834/c-sharp-xaml-how-to-modify-the-dimensions-of-the-rows-and-the-columns-of-a-grid

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
