Is there a WrapPanel (not WrapGrid) control in WinRT-XAML? - windows-8

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.
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?)

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

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.

Related

Fill width on Windows Phone 8.1

I'm developing an application using the Windows Phone 8.1 SDK, I write UI descriptions using XAML markup.
I can't get a text box to fill width.
I see similar questions already posted but they involve ListView.
I'm really confused. There seems to be no proportional sizing options.
Tutorials show the use of explicit pixel counts in design.
Is that really the preferred method on Windows? How am I supposed to
deal with unpredictable screen sizes in Windows?
The items which I had, which were failing to fill their parent, were inside a ContentControl. The ContentControl correctly filled its width, but its child, which was a Grid, would not.
I found the solution here – https://stackoverflow.com/a/17627257/5476004 – and I will echo that solution here in case this post is found by someone else searching about the same problem.
The ContentControl requires two special properties in order for its child element to fill the parent. They are HorizontalContentAlignment and VerticalContentAlignment. Like so":
<ContentControl Name="MyContent" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
…
</ContentControl>
Fill now occurs correctly.

Content control for complex layout

I start to learn winrt so I have question regarding containers in xaml.
I want to have on main screen of my app a set of different custom controls, but i want to have such interface like in Gridview (Horizontal scrolling, names for groups).
Yes, I can use GridView with different templates per item. But it's not a good solution.
For better explanation please review my picture. It's my goal.
How can I do this? Should i write some kind of custom GridView or there is already such or similar controls?
Thank you!
You can achieve this by using the following:-
-Scroll Viewer
- StackPanel (orientation horizontal)
-Grid view
-User Control
-...
If you are targeting 8.1 then you can use the new hubs which are designed exactly for the described scenario.

Why use XAML in visual studio express for windows 8?

i'm trying to do an application for Windows 8 and i'm following a guide on channel9.msdn
I cant understand why they use XAML to create textbox, label or other controls.
There's a reason ? There's a form which is much faster: simply drag & drop controls into the UI.
So why use XAML ?
Thanks all and sorry for my english :/
XAML supports laying out the form so that if you resize the window, the controls contained in the window are always consistently positioned according to the layout.
If you just drag and drop, you will see that the designers uses margins to position the controls. When you resize the window, they kind of keep the same position and are not going to be well positioned anymore.
This layouting is the essence of WPF. Just read a tutorial about layouting in WPF.
Drag and drop creation of UIs when using XAML creates very poorly formatted XAML and since there are a significant number of things which are most easily done in XAML (data templates for instance), it's easier to simply construct your UI in XAML from the start.

Is preparing Windows 8 XAML HubPages from several GridViews inside ScrollViewer the good approach?

I'd like to get the effect visible on the picture:
I don't think it is. A GridView already has a ScrollViewer in itself, so multiple of them does not make sense. I would try to use a single GridView with GroupStyleSelector/ItemContainerStyleSelector/ItemTemplateSelector implementations and DataTemplates to define each item. A less dynamic version might just be a ScrollViewer with Style set to HorizontalScrollViewerStyle, a horizontal StackPanel and a few VariableSizedWrapGrids - if you bind the GridView to some groups or other panels to define the content.
This looks like a good sample based on the description (though the images seem to be missing for me).

Hide objects/User Controls within WrapPanel?

I've got a WrapPanel which will contain several different custom UserControls. Depending on the scenario, I may need to filter down which UserControls are visible. My goal is that I can switch which controls are visible on the fly by showing/hiding the controls that need to be filtered - thus shifting the controls that are left showing, to the top-left of the panel.
Right now I am simply setting the Visibility property of the control to Visibility.Collapsed when I don't want them to appear. I thought that because I was using a WrapPanel, the rest of the controls would shift to the top-left of the panel.
Instead, after hiding some of the UserControls, the controls that are still visible stay exactly where they were before, and I am left with gaps between the controls that are still showing. I've opened my app in Silverlight Spy, and it shows that the UserControls are still actually there (which makes sense) but are simply invisible.
So my question is:
Is there a way that I can show/hide UserControls within a WrapPanel which allows the still-visible UserControls to slide to their new positions (all shifting towards the top left - similar to a StackPanel)?
I've debated removing the UserControls completely from the WrapPanel (I think this would work) and storing them in memory until they are needed. Then if I wanted to show/hide other controls, I would get them from my in-memory object. It seems like there should be a better way to do this though.
If anyone has any suggestions or advice, it would be greatly appreciated. Thanks!
-Lloyd
UPDATE:
XAML: (very simple)
<toolkit:WrapPanel x:Name="MyLayout" Height="300" HorizontalAlignment="Left" VerticalAlignment="Top" Width="400" />
Code-Behind: The UserControls are getting added dynamically:
MyLayout.Children.Add(oUserControl)
And they are getting set to collapsed dynamically as well:
oUserControl.Visibility = Visibility.Collapsed
I think I've found the problem. We added the WrapPanel to a ScrollViewer recently, and when I took the ScrollViewer out I was able to achieve the functionality I wanted.
I'm not sure why the ScrollViewer would have that effect though?
Also, I've found that I can leave the ScrollViewer in place and simply call .Measure() on the WrapPanel to update the layout.
Neither option makes 100% sense to me, but they do both seem to work.