nitish.mohiputlall -4 Junior Poster in Training

what are the codes to use to filter out my listbox as the user is typing in the textbox?

the data in my listbox is from database. I have used a relay command to get all the details of an Event then place the details in an observable collection. Then bind my listbox to the observable collection and a textblock to show the Event Names.

xaml codes:

<TextBox  x:Name="txtSearch" Background="White" FontSize="30"  Height="57" Margin="19,10,19,0" Grid.Row="1" />
<Grid Grid.Row="1" x:Name="ContentRoot" Margin="19,72,19,0">
        <ListBox Background="Black"  x:Name="listBox" FontSize="26" Margin="0,10,0,0" LayoutUpdated="listbox_layoutUpdate" ItemsSource="{Binding HomePage.SearchEventCollection}">
            <ListBox.ItemTemplate >
                    <StackPanel Orientation="Horizontal">
                        <TextBlock x:Name="txtEventName" TextWrapping="Wrap" Text="{Binding EventName}" Tapped="txtEventName_Tapped" IsTapEnabled="True" Foreground="White" Width="300" Margin="10,15,0,0" Height="55"/>

relay command in viewmodel:

private RelayCommand _eventSearch;

    /// <summary>
    /// Gets the EventSearch.
    /// </summary>
    public RelayCommand EventSearch
            return _eventSearch
                ?? (_eventSearch = new RelayCommand(
                async() =>
                    var eventList = await App.MobileService.GetTable<Event>().ToListAsync();

                    foreach (Event ename in eventList)
                        SearchEventCollection.Add(new Event
                            Id = ename.Id,
                            EventName = ename.EventName,
                            Date = ename.Date,
                            Location = ename.Location,
                            Desc = ename.Desc


private static ObservableCollection<Event> _searchEventCollection = new ObservableCollection<Event>();

    public static ObservableCollection<Event> SearchEventCollection
        get { return _searchEventCollection; }
        set { _searchEventCollection = value; }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.