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 7032035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:52:55+00:00 2026-05-28T00:52:55+00:00

When I make selection in ComboBox, and then type some text in TextBox, I

  • 0

When I make selection in ComboBox, and then type some text in TextBox, I want to have visible AutoSuggestion list of ID or FirstName or LastName (based on ComboBox Selection) that contains typed string in TextBox. Like this, now it works only for FirstName.

I have problem to somehow set dynamically binding for TextBlock.
Please Help.
Thanks in advance! Marina

I have ComboBox:

 <ComboBox Height="23" Name="cbAttrib" Width="120" Margin="0,8,0,0">
          <ComboBoxItem>ID</ComboBoxItem>
          <ComboBoxItem>FirstName</ComboBoxItem>
          <ComboBoxItem>LastName</ComboBoxItem>             
  </ComboBox>

I have TextBox:

<TextBox Name="txtSearch" TextChanged="txtAutoSuggestName_TextChanged"/>

And this ListBox:

 <ListBox Name="listBoxSuggestion" Visibility="Hidden" SelectionChanged="ListBox_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock DataContext="{Binding FirstName}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

and in code I have this methods:

private void txtAutoSuggestName_TextChanged(object sender, TextChangedEventArgs e)
    {
        listBoxSuggestion.Items.Clear();
        if (txtSearch.Text != "")
        {
            ComboBoxItem cb = (ComboBoxItem)cbAttrib.SelectedItem;                
            Collection<Person> namelist = proxy.PersonSearch(txtSearch.Text, cb.Content.ToString());               
            if (namelist.Count > 0)
            {                   
                listBoxSuggestion.Visibility = Visibility.Visible;
                foreach (var obj in namelist)
                {
                    listBoxSuggestion.Items.Add(obj);                        
                }
            }
        }
        else
        {
            listBoxSuggestion.Visibility = Visibility.Hidden;
        }
    }

    private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (e.AddedItems.Count > 0)
        {
            txtSearch.Text = (e.AddedItems[0] as Person).FirstName.ToString();
            listBoxSuggestion.Visibility = System.Windows.Visibility.Hidden;
        }
    }
  • 1 1 Answer
  • 0 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-28T00:52:55+00:00Added an answer on May 28, 2026 at 12:52 am

    You are not binding the Text so nothing will display

    You just bind the DataContext, which does nothing if there are no additional bindings which will be relative to it. Just swap that (or add Text="{Binding}" which will bind to the DataContext which is the FirstName) and if your logic is correct it should work.

    (Instead of clearing and adding to Items you should just set the ItemsSource instead. listBoxSuggestion.ItemsSource = namelist;)

    Edit: To make the binding work for different suggestions change the binding path to Value and make the ItemsSource a collection of some simple objects with a Value property (e.g. use LINQ and anonymous objects).

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

Sidebar

Related Questions

I have a dropdown box (Combobox). Everytime I make a new selection a table
I have an editable ComboBox with a validation on the Text property to make
I have a table : tags(tagname,entryid,stamp) and i want to make a section for
I need to have the user make a selection using radio button and the
I have a combobox that stays open if the user does not make a
I have a design question: If you had to make a WPF Combobox with
I basically want to make this in my application, so our technicians have an
Essentially what I want to do is make a selection on data displayed based
Goal: The user should not make any changes in the text field in Combobox.
I have a ComboBox with a remote json store. It lets the user type

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.