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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:17:24+00:00 2026-06-05T13:17:24+00:00

I have a listbox and a textbox. I want to handle its keyup event

  • 0

I have a listbox and a textbox. I want to handle its keyup event but its giving me an error.

<ListBox Name="lstSelectedNumber" Height="50" MaxHeight="120" VerticalAlignment="Top" Grid.Column="1" SelectionChanged="lstSelectedNumber_SelectionChanged">
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="ListBoxItem">
                                    <Setter Property="Padding" Value="-15" />
                                    <Setter Property="Margin" Value="0"/>
                                </Style>
                            </ListBox.ItemContainerStyle>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <toolkit:WrapPanel>
                                    </toolkit:WrapPanel>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel>
                                    <TextBox x:Name="txtNumber" Text="{Binding Name,Mode=TwoWay}" IsEnabled="{Binding IsEnabled,Mode=TwoWay}" Background="Transparent" Foreground="{StaticResource ContactSelectorBrush}" Style="{StaticResource DialNumberStyle}" FontSize="24" KeyUp="txtNumber_KeyUp">
                                        <TextBox.CaretBrush>
                                            <SolidColorBrush Color="{StaticResource CaretBrush}" />
                                        </TextBox.CaretBrush>
                                    </TextBox>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>



private void txtNumber_KeyUp(object sender, KeyEventArgs e)
      {
          TextBox txtbox = sender as TextBox;
          if (txtbox.Text.Contains(';'))
          { 
              lstSelectedNumber.ItemsSource = null;
              // My Application Got crashed at this point when i assign nullto item source
              lstSelectedNumber.ItemsSource = lstContactModel;
          }

Is there any alternate that my updated collection is itemsource of that listbox. please tell me any work around for that.

  • 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-06-05T13:17:25+00:00Added an answer on June 5, 2026 at 1:17 pm

    I Have Fixed This Issue Myself.
    The Problem is This When My textbox Event is Called It Do Some Changes in My List And Bind Empty Source To My Listbox And This Change Effects My UI And UI Is Unable To Handle That Change So I Put My All Code In Dispatcher So Once All The Things Are Done It Reflects Changes To UI and UI Accepts That

     private void txtNumber_KeyUp(object sender, KeyEventArgs e)
            {
                TextBox txtbox = sender as TextBox;
                if (txtbox.Text.Contains(';'))
                {
                    Dispatcher.BeginInvoke(() =>
                    { 
                        lstSelectedNumber.ItemsSource = null;
                        lstSelectedNumber.ItemsSource = lstContactModel;
                    });
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listbox & textbox above it. I want to the user to
I have TextBox and ListBox with bunch of elements. TextBox has KeyDown event handler,
I have a textbox, when its content changed, I want to query the xml
I have a ListBox with items that fill TextBox es. How do I identify
hello everybody i have a listbox within which is a datatemplate.Inside it is checkbox,textbox,label...Wat
I have a listbox on a page: <select id=user_list name=user_list size=21 style=width:200px;> <option value=1>User
I have a ListBox ( MyListBox ) on my screen, and a Textbox (
I have a UserControl that incorporates a textbox. I want to set the keyboardfocus
I have a WPF listbox control that is declaratively bound to a textbox. The
I have a listbox, I want to get the value onclick and copy it

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.