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?