Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
XamDialogWindow Tile
posted

I am using the Infragistics XamDialogWindow to approximate an MDI window in WPF.

Basically I have a user control that I assign to the content of the window and then add the XamDialogWindow as a child of a Grid.

I then have two buttons which display the windows as either "Tile" or "Cascade".

The cascade works really well but I am having problems with the Tile method.

I get the available width and height using the "ActualWidth" and "ActualHeight" properties of the container.

I then calculate the number of rows and columns needed.

Next I iterate through the columns and I calculate how many rows there are in a column, (this means that if there are an odd number of windows such as 5 I will have two rows in column 0 and 3 in column 1).

The width of each window is worked out as "AvailableWidth / numColumns"

The height of each window is worked out as "AvailableHeight / WindowsForThisColumn"

I then iterate through the rows and calculate the top left coordinate of the window we are positioning as follows:

left = columnIndex * width

top = rowIndex * height

The Left, Top, Width and Height properties of the window are then set.

PROBLEM

The Left, Top, Width and Height properties seem to be calculated correctly so for example

  • AvailableWidth = 1000;
  • AvailableHeight = 1000;
  • Window1 = 0, 0, 500, 500
  • Window2 = 0, 500, 500, 500
  • Window3 = 500, 0,500, 500
  • Window4 = 500, 500, 500, 500

This should give a nice grid of 4 windows with no margins filling all available space, however this is not the result.

The windows seem to be offset when displayed (see image attached).

If I look at the Left, Top, Width and Height properties they all appear to be correct.

The weird thing is, if I click "Tile" a second time they will all appear correctly.

If I move a window after clicking tile the second time, they will appear correctly.

I have tried using a Canvas and setting the Canvas.Left and Top properties, A grid, stackpanel and wrappanel with the same results every time.