Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:08:23+00:00 2026-05-20T11:08:23+00:00

I am wondering if someone can share with information or good sample with filtering

  • 0

I am wondering if someone can share with information or good sample with filtering listboxitems based on what is typed in the textbox. Perhaps, it can be a different control that fits better to the scenario below.

In my scenario, I need to type a short string in texblock. Then, click ‘check’ button which will find the closest string values of items from the collection and show these matches in a form of the list below the textblock. Selecting any of items from shown list of items will place the selected string/item in the tetxblock. The behavior is very similar to combox box.

Finally, I need to be able to add that selected string/item that was placed in the texblock to another listbox by clicking ‘Add’ button. Any ideas are highly appreciated. Thank you in advance!

Below is my XAML code:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
x:Class="FilterListItems.MainPage"
xmlns:local="clr-namespace:FilterListItems"
Width="640" Height="480">

<UserControl.Resources>   
    <local:Products x:Key="productCollection" />
    <CollectionViewSource x:Key="collProducts" Source="{Binding Source={StaticResource productCollection}, Path=DataCollection}">
</CollectionViewSource>
</UserControl.Resources> 
<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="10" Grid.Row="0">
  <TextBlock Text="Enter Partial Name: " />
  <TextBox Width="100" Name="txtName" />
  <Button Name="btnSearch" Content="Check" Click="btn_Check" />
  <Button Name="btnAdd" Content="Add" Click="btn_Add" Margin="9,0,0,0" />
</StackPanel>
<ListBox Margin="10" Grid.Row="1" Name="lstData" DisplayMemberPath="ProductName"  ItemsSource="{Binding Source={StaticResource collProducts}}" Visibility="Collapsed" />
<ListBox Margin="10" Grid.Row="2" Name="2stData" />

C# to generate the collection:

public partial class MainPage : UserControl
{
    public MainPage()
    {
        // Required to initialize variables
        InitializeComponent();
    }

    private void btnSearch_Click(object sender, RoutedEventArgs e)
    {
        //FilterData();
    }
}


public class Product
{
    public Product(int id, string name)
    {
      ProductId = id;
      ProductName = name;
    }

    public int ProductId { get; set; }
    public string ProductName { get; set; }
    }

public class Products : List<Product>
{


    public Products()
    {
        InitCollection();
    }

    public List<Product> DataCollection { get; set; }

    List<Product> InitCollection()
    {
        DataCollection = new List<Product>();

        DataCollection.Add(new Product(1, "aaa"));
        DataCollection.Add(new Product(2, "bbb"));
        DataCollection.Add(new Product(3, "ccc"));
        DataCollection.Add(new Product(4, "ddd"));
        DataCollection.Add(new Product(5, "eee"));
        DataCollection.Add(new Product(6, "fff"));
        DataCollection.Add(new Product(7, "hhh"));
        DataCollection.Add(new Product(8, "ggg"));

        return DataCollection;
    }
}
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:08:24+00:00Added an answer on May 20, 2026 at 11:08 am

    Check out the AutoCompleteBox from wpftoolkit

    also check

    http://www.jeff.wilcox.name/2010/02/wpfautocompletebox/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wondering if there if someone can share with a good sample of
I am wondering if someone can share or point to good samples of datagrid
I am wondering if someone can put a bit of an authoritative reference summary
I am wondering if someone can help me figure out the best approach to
I was wondering if someone can help me out - working on a bit
I am wondering if someone can explain why dispatching back to the main queue
I was wondering if someone can help me out with this issue. I have
Apologies for the long code post but am wondering if someone can help with
I'm a pretty new C# programmer. I was wondering if someone can fill me
I am wondering if someone could explain how I can utilise tags in an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.