Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Grid: Is there an easy way to readjust the row items if I need to insert new rows?

Tags:

insert

wpf

row

grid

It appears that grid row and column definitions are hard-coded like this:

Grid.Row="3" Grid.Column="1" 

I am in the middle of development on a new WPF app and I am having to constantly add and delete new rows from my grid as the client makes up their mind on how the form should look. I am discovering that this is quite a tedious task. If insert a row near the top, I have to manually change all the row indexes in the XAML beneath the row I just inserted.

Is there an easy way to auto-adjust all the rows?

like image 352
oscilatingcretin Avatar asked May 19 '11 13:05

oscilatingcretin


People also ask

How do I create a dynamic grid in WPF?

The Grid class in WPF represents a Grid control. The following code snippet creates a Grid control, sets its width, horizontal alignment, vertical alignment, show grid lines, and background color. Grid DynamicGrid = new Grid();

How do I move the grid in WPF?

Just put the grid panel inside a canvas rather than directly into the window - this will then give it X/Y co-ordinates.

What is grid splitter in WPF?

A GridSplitter is a divider that divides a Grid into two sections. A GridSplitter allows us to resize rows or columns in a Grid by dragging the GridSplitter Bar. An example of a GridSplitter is the Windows Explorer.


Video Answer


1 Answers

In Visual Studio 2015 you can also hover over the edge of a row and a little dropdown box will appear. When you click the down arrow two of the options are "move row before" and "move row after". That's the best way I've found.

Example image:

screenshot

like image 72
BoomBaby Avatar answered Sep 23 '22 23:09

BoomBaby