This is a migrated thread and some comments may be shown as answers.

Speed up RadListBox

4 Answers 325 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Paweł
Top achievements
Rank 1
Paweł asked on 02 Jul 2013, 03:45 PM

Hello.
I need to load large data as RadListBoxItems with template like.
My code:
<telerik:RadListBox Name="testlv">
                <telerik:RadListBox.ItemTemplate>
                    <DataTemplate>
                        <Border BorderBrush="Turquoise" BorderThickness="0,1,0,1" Width="{Binding Path=ActualWidth, ElementName=grdzero}">
                            <WrapPanel Orientation="Vertical" >
                                <TextBlock Foreground="Black" Text="{Binding nazwa}" FontSize="16"></TextBlock>
                                <WrapPanel Orientation="Horizontal">
                                    <TextBlock Foreground="Black" Text="Cena: "  FontSize="16"></TextBlock>
                                    <TextBlock Foreground="Black" Text="{Binding cena}"  FontSize="16"></TextBlock>
                                </WrapPanel>
                                <WrapPanel Orientation="Horizontal">
                                    <TextBlock Foreground="Black" Text="Kod: "  FontSize="16"></TextBlock>
                                    <TextBlock Foreground="Black" Text="{Binding kod}"  FontSize="16"></TextBlock>
                                </WrapPanel>
                            </WrapPanel>
                        </Border>
                    </DataTemplate>
                </telerik:RadListBox.ItemTemplate>
            </telerik:RadListBox>


And code behind:
private void getProducts(string query)
      {
          prodDG.Items.Clear();
          List<SearchProd> pL = FastSellSearchClass.lista.Where(x => x.nazwa.ToLower().Contains(query.ToLower()) || x.kod.Contains(query) && x.wID == int.Parse(Application.Current.Properties["warehouseID"].ToString())).ToList();
          testlv.ItemsSource = pL;
}

List<searchProd> represent list of product. It work's like:
client press any key in keyboard, which open new window with radListBox, insert pressed key into textBox, and going into
getProducts(string query) to filter items (where query = pressed key).
So for example when somebody press 'S', it will search for items, where name or code contains 'S'.

Problem is that, with 3000 products page is loading for like 9-10 second.
When it's loaded, it tooks less than second to find any words with 'Sa' for example.
So is there any way to speed up opening window a little bit?

4 Answers, 1 is accepted

Sort by
0
Paweł
Top achievements
Rank 1
answered on 02 Jul 2013, 03:59 PM
And there is funny fact. I've put DateTime start and DateTime end.
DateTime start is set before InitializeComponent();
DateTime end is set in Window.Loaded.
Both of them is set to DateTime.Now. And TimeSpan shows me .TotalSeconds = end-start - so it represents total time to load window.
Now something funny:

Total time when LOADING DATA (3000+ items into ListBox, with template as in first post):
Time is (sec) :3,0521746
Total time when NOT LOADING DATA - just to build page, with comments in 3 line :
//prodDG.Items.Clear();
          //List<SearchProd> pL = FastSellSearchClass.lista.Where(x => x.nazwa.ToLower().Contains(query.ToLower()) || x.kod.Contains(query) && x.wID == int.Parse(Application.Current.Properties["warehouseID"].ToString())).ToList();
          //testlv.ItemsSource = pL;

Time is (sec): 3,0821763

Values are almost the same.
So i have to understand it as : loading any telerik control took 3 second in quiet fast PC. Loading data tooks less than 1 sec.
Is that any bug in telerik controls or what, becouse I really dont understand it.
0
Vladi
Telerik team
answered on 05 Jul 2013, 11:58 AM
Hello Paweł,

Thank you for contacting us.

We tried to reproduce the issue but to not avail. When a collection of 3000 items is bound to the ItemsSource of the RadListBox control no performance issue was observed. You should note that if all of the items are visible when loaded (no vertical scrollbar is shown, or with other words the ListBox is placed inside a panel with no Height set to it for example a StackPanel) it takes around 5-6 sec for those items to be visualized. This approach is breaking the built-in virtualization of the control and there could be some performance issues. This is common approach that would break the built-in virtualization of any WPF ItemsControl.

I attached the sample project in which I tested the issue for you. Please give it a try and let me know if I have missed something.

Regards,
Vladi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Paweł
Top achievements
Rank 1
answered on 16 Oct 2013, 03:33 PM
Hello.
Actually I forgot about that topic - so sorry for that you need to wait so long.
Actually at this momment im not loading items when window is loaded (and for sure window loading for like 0,5 sec).

But reffering to your answer - when 'control' is inside (for example stackPanel) another 'control' without specific width/heigh - I have question.
I have also problems with loading data into radGridView - tooks couple second to load gridview with 1000+ items. Gridviews are inside grid row/column with width/height set as '*' - which is I guess not so good idea. Problem is that - im not sure which resolution client will choose. For example in resolution 1366/768 gridView h/w = 1130/800, with 800/600 will be another. So is there any way to set (in xaml file) size according to client resolution?
0
Vladi
Telerik team
answered on 17 Oct 2013, 12:14 PM
Hi,

We are not aware of an approach that we can share with you that will set a fix size to the Container of the RadGridView based on the current video resolution.

You can take a look at this help article that describes possible approaches in optimizing the performance of the control, hope this is helpful.

Regards,
Vladi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ListBox
Asked by
Paweł
Top achievements
Rank 1
Answers by
Paweł
Top achievements
Rank 1
Vladi
Telerik team
Share this question
or