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

  • Home
  • SEARCH
  • 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 147397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:46:28+00:00 2026-05-11T08:46:28+00:00

I have a listbox with a bunch of contols in each list item. <ListBox

  • 0

I have a listbox with a bunch of contols in each list item.

<ListBox x:Name='projectList' IsSynchronizedWithCurrentItem='True'>     <ListBox.ItemTemplate>         <DataTemplate>             <StackPanel>                 <TextBlock Text='{Binding Name}' />                 <ListBox x:Name='taskList' ItemsSource='{Binding Tasks}'>                     <ListBox.ItemTemplate>                         <DataTemplate>                             <StackPanel>                                 <TextBlock Text='{Binding Name}' />                             </StackPanel>                         </DataTemplate>                     </ListBox.ItemTemplate>                 </ListBox>                 <TextBox x:Name='textBoxTask' />                 <Button                     x:Name='ButtonAddNewTask'                     Content='Test'                     CommandParameter='{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext}'                     Click='ButtonAddNewTask_Click'                     />             </StackPanel>         </DataTemplate>     </ListBox.ItemTemplate> </ListBox> 

When I click on the button in the listbox i want to add a new item to the listbox within the listbox. I’ve come this far. So my question is how do I get hold of the textbox and how do I update the listbox?

Here is my click event

private void ButtonAddNewTask_Click(object sender, RoutedEventArgs e) {     Button button = (Button)sender;     Project proj = button.DataContext as Project;     if(proj.Tasks == null)         proj.Tasks = new List<Task>();      proj.Tasks.Add(new Task('Added Task')); } 

Thanx

  • 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. 2026-05-11T08:46:28+00:00Added an answer on May 11, 2026 at 8:46 am

    This solution worked for the task at hand so to speak.

        private void ButtonAddNewTask_Click(object sender, RoutedEventArgs e)     {         Button button = (Button)sender;         DependencyObject obj = LogicalTreeHelper.GetParent(button);         StackPanel item = obj as StackPanel;         TextBox textBox = item.FindName('textBoxTask') as TextBox;         ListBox listBox = item.FindName('taskList') as ListBox;          Project proj = button.DataContext as Project;         if(proj.Tasks == null)             proj.Tasks = new List<Task>();          listBox.ItemsSource = proj.Tasks;         listBox.Items.Refresh();     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The rule is complaining because it is possible for a… May 11, 2026 at 11:31 am
  • added an answer That would make predicting the output really simple. Say, for… May 11, 2026 at 11:31 am
  • added an answer In my experience, it can be done and works fine.… May 11, 2026 at 11:31 am

Related Questions

I have a ListBox with a bunch of images in it (done through a
I have a ListBox with a StackPanel that contains an image and label. <ListBox.ItemsPanel>
I have a ListBox with way too many items in it and the UI
I have a screen with a ListBox of items. The item template contains an
I have a winform with a listbox and a treeview. Once my listbox is
I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with
In the example below I have a ListBox with dozens of font names in
I have a listbox on an HTML form with a Submit button. The listbox
With a listbox, I have the following code to extract the item selected: private
I have a ListBox that has a style defined for ListBoxItems. Inside this style,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.