0

WrapPanel is not supported by WinRT, as such I am using this code: http://www.codeproject.com/Articles/24141/WrapPanel-for-Silverlight-2-0

I've found a problem with using this code in a Grid. Any controls rendered in the row after I place the WrapPanel in, render OVER the WrapPanel in the same row.

It's almost as though the Grid doesn't recognise that WrapPanel is rendering content and so all controls in the following rows take it's place.

See image as an example.

enter image description here

Any ideas on how to resolve this?

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
c0D3l0g1c
  • 3,020
  • 5
  • 33
  • 71
  • 1
    Aren't they supposed to render on top of the WrapPanel if they are added to the parent Grid after the WrapPanel? BTW, there's a version of `WrapPanel` ported from Silverlight Toolkit to WinRT in the WinRT XAML Toolkit [here](http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/4d568d4e4c6a#WinRTXamlToolkit/Controls/WrapPanel/WrapPanel.cs). You should be able to control the rendering order of child items of a Grid by setting `Canvas.ZIndex` values of these controls to match the desired rendering order. I think that doesn't work in custom panels, but should work for a `Grid`. – Filip Skakun Feb 05 '13 at 20:30
  • Another implementation of the `WrapPanel` is in the Q42 library here: https://github.com/Q42/Q42.WinRT/blob/master/Q42.WinRT/Controls/WrapPanel.cs – Filip Skakun Feb 05 '13 at 20:31
  • A separate cell is dedicated for the WrapPanel and every control that follows it. Controls should only render ontop of one another in a Grid if they are added to the same cell. As i said, in this case they are all separated, but yet are rendering ontop of the WrapPanel. – c0D3l0g1c Feb 06 '13 at 06:57
  • Maybe that version doesn't report its Width/Height properly, ending up with 0, so your parent Grid would not dedicate any space to the WrapPanel's row. Check that or try another implementation. – Filip Skakun Feb 06 '13 at 07:21
  • 1
    WinRT XAML Toolkit WrapPanel works perfectly! Thanks. – c0D3l0g1c Feb 06 '13 at 15:25

1 Answers1

2

Seems like the implementation you are using doesn't measure the size of the panel correctly. If the size it returns from a measure pass is 0 then the Grid with RowDefinition Height="Auto" will make a row with a height of 0, so if anything gets rendered in that row that isn't clipped - it will render under the content of the next row. It seems like the WinRT XAML Toolkit version of the WrapPanel ported from Silverlight Toolkit works well for you. Here is the link for anyone else to use it too: http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/4d568d4e4c6a#WinRTXamlToolkit/Controls/WrapPanel/WrapPanel.cs

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100