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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:16:23+00:00 2026-05-13T07:16:23+00:00

The functionality I want is to have a remove button beside each item of

  • 0

The functionality I want is to have a remove button beside each item of a listbox so when the user clicks it, that specific item gets removed from the list.

I am thinking about putting it in the data template but how would I wire up an even to that?

Thanks,
Shawn Mclean

  • 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-13T07:16:23+00:00Added an answer on May 13, 2026 at 7:16 am

    Here is one way to approach this issue. Create an ObservableCollection and set you ItemsSource equal to that Collection. Then your Button click handler can just remove the item.

    using System;
    using System.Collections.ObjectModel;
    using System.Windows.Controls;
    
    namespace SilverlightApplication1
    {
        public partial class MainPage : UserControl
        {
            private ObservableCollection<string> _customers;
    
            public MainPage()
            {
                InitializeComponent();
    
                _customers = new ObservableCollection<string>() { "Bob", "Mark", "Steve" };
                this.DataContext = _customers;
            }
    
            public void remove_Click(object sender, EventArgs e)
            {
                var button = sender as Button;
                if (button == null)
                    return;
    
                var name = button.DataContext as string;
                if (string.IsNullOrEmpty(name))
                    return;
    
                _customers.Remove(name);
            }
        }
    }
    

    In this sample your XAML would look like this:

    <Grid x:Name="LayoutRoot">
        <ListBox ItemsSource="{Binding}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock Text="{Binding}" />
                        <Button Content="Remove" Click="remove_Click" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to include a batch file rename functionality in my application. A user
I want to implement search functionality for a website (assume it is similar to
I want to extend a WPF application with database functionality. Which database engine would
I have a windows gui built in Microsoft Visual C++ and when the user
I have jquery code that is being reused by a repeatable partial view on
What functionality does the yield keyword in Python provide? For example, I'm trying to
When prototyping initial GUI functionality with a customer is it better to use a
I need to add functionality to my J2EE-based wep application: 1) Take some page,
The print functionality of Excel (using VBA) is extremely slow. I'm hoping someone has
I'm converting functionality from an asp.net Gridview to a Listview. In the gridview when

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.