Is there a WrapPanel (not WrapGrid) control in WinRT-XAML?
Asked Answered
R

2

21

A XAML StackPanel aligns controls side-by-side in a single direction. A WrapPanel is similar but like TextWrapping="Wrap" in a XAML TextBox the controls "wrap" to the next column or row when the respective height or width is reached.

enter image description here

Similar, but not the same, WrapGrid wraps content, but in a uniform grid. Though the VariableSizedWrapGrid allows for dissimilar items in the container. Neither of the WrapGrids can be used outside of an ItemsControl. So, they are disqualified.

When developers look in their native XAML Toolbox in Visual Studio there is no WrapPanel. WPF developers had a WrapPanel so they might be looking for this common tool to solve their scenario. So, I have to ask:

Does anyone know of a WrapPanel in XAML-WinRT? (what about one that is virtualized?)

Roseola answered 31/5, 2013 at 15:27 Comment(1)
+1 I have been looking for this very same thing. It is a pain to have to manually set the rows and columns of each item in a gridview. I think it can be done by overriding ArrangeOveride. I had a failed attempt at it once, and haven't looked at it again. ArrangeOverride at MSDN: msdn.microsoft.com/en-us/library/windows/apps/…Paraphernalia
C
9

There is one in WinRT XAML Toolkit here. It was ported from Silverlight Toolkit.

Commendatory answered 31/5, 2013 at 21:43 Comment(7)
As long as we understand the answer is "no", Filip, I will mark this as the correct answer. There is no WrapPanel in WinRT. There are open source and third party WrapPanels, however. Mine is here: codepaste.net/8gr5goRoseola
Tim also has one. I think from the same source as mine.Commendatory
Yeah, mine is based on a version somewhere on CodeProject. I emailed the guy and asked if I could absorb it. For all I know his is based on the Toolkit, too. A lot of clipboard Inheritance on the web.Roseola
Looks good and works, but I am confused about the license. On the project page it says it's released under the MIT License, but in the header of the WrapGrid code the Ms-PL license is mentioned, which seems to be an "infectious" Open Source license. So, can I use it in commercial, proprietary, closed-source software, or not?Kalin
The WrapPanel from the WinRT XAML Toolkit is definitely better than the one from CodeProject that Jerry Nixon used.Freely
I am creating a Windows Phone 8.1 (WinRT) application. The template is a two GridView (2 grids per row) and the height of grid varies (one item might occupy one row and other might occupy two rows). I was able to achieve it using VariableSizedGridView and I did lazy loading as well. But I could find that there is no virtualization because of which the memory goes on increasing on scrolling down. Can you suggest me the how to achieve variable sized grid with virtualization like the pin.it app? bit.ly/1Y3X5DlPasha
Group your items source into pairs and use a regular ListView where each ListViewItem can display two items.Commendatory
L
0

I had a same requirement and after googled it for a while, I've decided to use custom control for this. Please find following link for implementation:

http://www.codeproject.com/Articles/463860/WinRT-Custom-WrapPanel

Hope this will help you.

Lippizaner answered 23/1, 2015 at 4:41 Comment(1)
Vishal. I don't see the advantage of your control to WrapGrid, since, as far as I understand, it assumes fixed element size (width for Horizontal orientation). The whole idea is to allow variable element width, so that you dynamically check if the new element fits in and place it on next line, if it doesn't.Hepatitis

© 2022 - 2024 — McMap. All rights reserved.