I have a listbox in xaml.I have to fetch a list of string from database and then have to display them in the listbox.The count of the items can be maximum 30,000.
I am fetching the data but when I am adding it in the listbox it crashes giving "Out of Memory Exception".
My Code:-
List
Dispatcher.BeginInvoke(() =>
{
listbox.Items.Clear();
foreach (string str in lstOfVals)
{
TextPhoneControl tpc = new TextPhoneControl ();
tpc.shorthandValue.Text = str;
listbox.Items.Add(tpc);
}
});
Gokhul VarmanPosted Jul 28, 2017, 5:08 AM
Asfend YarPosted Mar 2, 2016, 3:12 PM
Sweta SinhaPosted Mar 3, 2015, 6:39 AM
VulpesPosted Mar 3, 2015, 6:16 AM
Sweta SinhaPosted Mar 3, 2015, 5:50 AM
VulpesPosted Mar 3, 2015, 5:48 AM
If you just add the strings themselves it will save a lot of memory.