ISupportIncrementalLoading combined with VariableSizedWrapGrid - xaml

I have an ObservableCollection<T> which implements the ISupportIncrementalLoading interface.
When I bind this collection to a normal gridview, everything works fine.
But when I change the ItemsPanel template, to VariableSizedWrapGrid. The incremental loading doesn't work any more.
Xaml that works:
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
Xaml that doesn't work:
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" ItemHeight="250" ItemWidth="250" Margin="0,0,80,0"/>
</ItemsPanelTemplate>
I've also found this & this. Stating the VariableSizedWrapGrid doesn't support ISupportIncremetalLoading.
Is there anyone that have written a VariableSizedWrapGrid, that supports Incremental loading? Or an opensource solution?

There are only two panels that support the incremental loading: VirtualizingStackPanel and WrapGrid. I do not know about any open-source solution.

It does not support because the panel itself has to be able to virtualize elements. Since the datatemplates insice a VariableSizedWrapGrid are different, is not possible to virtualize, so every element you want to draw has to be present at the begining.

Related

Strange behaviour of combobox in WinRT

Comboboxes in WinRT have a default ItemsPanel of type CarouselPanel. This gives Windows 8.1 apps an "infinite loop" when scrolling combobox items.
If you don't want this behaviour, there are a lot of blog posts explaining how to "fix it".
For example this: Cancel WinRT ComboBox infinte scroll effect
or: http://netitude.bc3tech.net/2013/04/12/windows-8s-combobox-and-the-carouselpanel/
The problem with this solution is that you get a weird behaviour on the first item in the combobox.
How to reproduce:
Create a new blank Windows 8.1 app
In mainpage.xaml put:
<TimePicker Time="0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
Create a style.xaml resource dictionary like this:
<Style TargetType="ComboBox">
<Style.Setters>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
Now start the app, select an item down the list (for example '05' minutes), then select the first item in the same dropdown (for example '00' minutes). The text in the dropdown control will now disappear.
Anyone know how to fix this? If I change the style of combobox itemspanel back to CarouselPanel it works (but with the infinite loop of course).
Just corrected this issue using a VirtualizingStackPanel in place of a StackPanel.
We had to set a size cause otherthise it take all the width of the screen.
<VirtualizingStackPanel HorizontalAlignment="Center" Width="150"/>
We didn't try to get a more flexible solution because we don't need it yet
Hope it will help you
StackPanel just not working with ComoboBox the possible solution is changing it to VirtualizingStackPanel, but you must bind with to the parent, otherthise it will stretch to screen width.
<ComboBox Name="ReasonComboBox"">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Width="{Binding ActualWidth, ElementName=ReasonComboBox}"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>

Placing an element exactly below another one on WP8?

I would like to place a GRID element just below another GRID element using XAML just like Android's layout below. How can it be done, if possible?
Is this all you're looking for?
<StackPanel>
<Grid/>
<Grid/>
</StackPanel>

How to manipulate items in C#

I'm making a Windows Store App using C# and XAML. How can I manipulate one single item in a GridView or a ListView?
According to certain logical conditions, I need to load or not the item in these containers. I have already tried using the property Visibility.Collapsed and Visibility.Visible of the item, but this just hides or shows the item and it is still loaded in the GridView/ListView, and is selectable.
Thanks for your help.
I reckon you meant to hide your GridViewItem without keeping space in view.
You just need to replace GridView's ItemsPanel with StackPanel or VirtualizingStackPanel.
<GridView>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>

Trouble laying out GridView contents?

I have this grid-view loading dynamic content correctly. However I can't quite figure out how to make it fill how I want. I want the content to start in the upper left corner and then create instance going downward until no more can fit (This should be 4) then start back at the top to the right of the original item.
The maxRowsOrCols property give me the behavior I desire, but I will definitely be exceeding 4 columns.
Please teach me.
You can use an ItemsPanel with the WrapGrid. The Orientation property is Horizontal or Vertical first. This should allow you to set your layout as required, depending on screen size and ItemTemplate.
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid MaximiumRowsOrColumns="4" Orientation="Vertical"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>

Referencing an item in a VirtualizingStackPanel

I'm playing with the "Grid Application," which is a C++ Metro app template provided by VS11. The main display is a collection of items displayed in a VirtualizingStackPanel:
<ScrollViewer x:name="itemGridScrollViewer">
<GridView x:name="itemGridView">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</ScrollViewer>
The actual items are displayed using the Standard250x250ItemTemplate data template defined in StandardStyles.xaml. One of the display elements of this is a graphic.
I'm trying to understand how to reference a specific item so that I can change the graphic at runtime. The ScrollViewer and the GridView have objects associated with them, so I can get to those, but I don't see how to get from there to the individual items.
All this stuff is completely new to me, so be gentle. :)
In general it's not a good idea to dig down into individual templated items in an ItemsControl because not only is it a pain, but that ItemTemplate can regenerate at different times (paging during virtualization, source collection updates, etc) and you'll be left holding an outdated UIElement that's no longer being displayed.
A better approach is to pull the data you need into the item data and in the ItemTemplate use Data Binding to make whatever changes you need to differentiate the UI. One option is to use an IValueConverter to get a different image depending on some state in the item data:
<GridView>
<GridView.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Path=DataState, Converter={StaticResource MyStateToImageConverter}}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
Here I'm assuming that the converter code has been written and an instance of the converter has already been declared as a resource (see here). You could alternatively do a direct Binding to a property on each item's data that specifies its image and skip the converter part.