Ordering in VirtualizingWrapPanel

2 Answers 42 Views
VirtualizingWrapPanel
Giuliano
Top achievements
Rank 1
Giuliano asked on 22 Mar 2024, 06:22 PM

I'm using a VirtualizingWrapPanel as the ItemsPanelTemplate of a RadListBox

<telerik:RadListBox x:Name="ItemControl"
                    Grid.Row="1"
                    VirtualizingPanel.ScrollUnit="Pixel"
                    ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UserControl}}, Path=PathName}">

    <telerik:RadListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <telerik:VirtualizingWrapPanel HorizontalAlignment="Center" ItemWidth="200" ItemHeight="180"/>
        </ItemsPanelTemplate>
    </telerik:RadListBox.ItemsPanel>

The ItemsSource is a ListCollectionView which is Live updating 

 


ListCollectionView = new(Models);
ListCollectionView.IsLiveSorting = true;

ListCollectionView.SortDescriptions.Add(new SortDescription("Percentage", ListSortDirection.Ascending));

The collection seems to be updating and reaching the UI; however, every so often I get empty cells in the RadListBox after a sorting happens.


If I scroll away and come back the area is filled in. Is there something I can do manually so that this area is filled in? Should I try reloading something in some way?

 

I've tried invalidating things in the wrap panel but this hasn't worked:

wrapPanel?.InvalidateArrange();
wrapPanel?.InvalidateMeasure();
wrapPanel?.InvalidateVisual();
wrapPanel?.UpdateLayout();

 

Any help or suggestions are appreciated

Dimitar
Telerik team
commented on 25 Mar 2024, 10:03 AM

Hi Giuliano, 

I have tested this but it seems to work on my side. I have attached my test project. Could you please check it and let me know what I need to change to reproduce this?

I am looking forward to your reply.

Giuliano
Top achievements
Rank 1
commented on 25 Mar 2024, 04:39 PM | edited

I was able to replicate the issue with a few changes. I made changes so that the collection is constantly updating that way it needs to be sorted more than once. I also moved 

Data.IsLiveSorting = true;
Data.SortDescriptions.Add(new SortDescription("PathName", ListSortDirection.Descending));

into the constructor of MyViewModel. 

 

 

In my application I don't plan on there being a sort button. I thought that binding to ListCollectionView and making IsLiveSorting true would sort the collection without it needing to be prompted. I would be ok with prompting it but on larger collections that require a scroll bar the sort button is sending the scroll bar to the top. Also, I'm using 2023.1.117 as my Telerik version. I'm not sure if the problem persists in newer versions. I've attached the project with the modifications.

2 Answers, 1 is accepted

Sort by
1
Accepted
Martin Ivanov
Telerik team
answered on 26 Mar 2024, 03:37 PM

Hello Giuliano,

To work this around, you can try the following idea. Youc an create a custom class that derives from VirtualizingWrapPanel and override its OnItemsChanged method. Then, execute the base method only if the args.Action is not Move.

public class CustomVirtualizingWrapPanel : VirtualizingWrapPanel
{
	protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
	{
		if (args.Action != NotifyCollectionChangedAction.Move)
		{
			base.OnItemsChanged(sender, args);
		}
	}
}

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Giuliano
Top achievements
Rank 1
commented on 26 Mar 2024, 04:41 PM

Thank you. This does appear to be working. I'll use this work around for now.
1
Dimitar
Telerik team
answered on 26 Mar 2024, 02:34 PM | edited on 26 Mar 2024, 03:24 PM

Hi Giuliano,

I was able to reproduce this issue. I have logged it on our behalf. You can track its progress, subscribe to status changes, and add your comment to it here: VirtualizingWrapPanel: Missing item containers when move action is executed over the items collection at runtime

I am afraid I cannot suggest a workaround for this issue. 

I want to apologize for the inconvenience this is causing you.

Regards,
Dimitar
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Giuliano
Top achievements
Rank 1
commented on 26 Mar 2024, 04:41 PM

Thank you. I added a link to this forum post. I'll keep track of the ticket.
Tags
VirtualizingWrapPanel
Asked by
Giuliano
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Dimitar
Telerik team
Share this question
or