1. quanlich's Avatar

    I'm currently writing a dictionary app using databound app template. My database is a sqlite database with more than 300.000 rows. Here is my code to store loaded database.

     public class Word
            public int Id { get; set; }
            public string WordString { get; set; }
            public string Content { get; set; }
     public class WordList
            public ObservableCollection<Word> Items { get; set; }
            public WordList()
                Items = new ObservableCollection<Word>();
    public class ViewModel {
           public async void LoadData()
                var query =  DB.Table<Word>();
                var result = await query.ToListAsync();
                foreach (Word w in result)
                    WList.Items.Add( new Word()
                        Id = w.Id,
                        WordString = w.WordString,
                        Content = w.Content
                IsDataLoaded = true;
    And I use a TextBlock to display wordString and a phoneTextBox to search words.

     <toolkit:PhoneTextBox Hint="Search"
                                      VerticalAlignment="Top" />
    <TextBlock Text="{Binding WordString}"
                                           Grid.Row="0" />
    And here is the code for searching:

     private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)        {
    IList<Word> results = App.ViewModel.WList.Items
                .Where(tb =>tb.WordString.StartWith(SearchBox.Text))
         ListBox1.ItemsSource = results;}
    The problem is when I do a search, it takes to long to response.
    Could you please give me a hint to accelerate my search? Could I create an indexer on ObservableCollection?

    Thanks in advance.
    03-02-2014 11:35 AM
  2. Catholic Tech Geek's Avatar
    Instead of using StartsWiith(),you could try using the overloaded IndexOf(string, startindex, count) for String. This is just an idea.

    example: exstring.IndexOf(SearchBox.Text, 0, SearchBox.Text.Length);
    03-02-2014 10:56 PM
  3. quanlich's Avatar
    Thank Catholic but it doesn't help much. It even made the app crash.

    I tried to change observableCollection to other collections like Dictionary, List, HashShet... but I don't know why they do not display data on ListBox? Only ObservableCollection which functions!!
    03-03-2014 12:11 AM

Similar Threads

  1. Hotmail / outlook.com not syncing with phone / PC Outlook
    By Ed Bradburn in forum Windows Phone 8
    Replies: 13
    Last Post: 08-04-2016, 03:42 AM
  2. Surface 2 Crackling Sound with Amazon Instant Video
    By angusdegraosta in forum Microsoft Surface 2
    Replies: 33
    Last Post: 12-29-2015, 09:39 PM
  3. What earphones are you using with the Ativ?
    By Loco5150 in forum Samsung ATIV S
    Replies: 20
    Last Post: 05-12-2014, 12:17 AM
  4. Replies: 6
    Last Post: 04-07-2014, 11:05 PM
  5. Any improvement with the camera after update
    By maverick786us in forum Nokia Lumia 1520
    Replies: 6
    Last Post: 03-02-2014, 12:18 PM