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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:42:19+00:00 2026-06-17T09:42:19+00:00

I have been working on a checklist application, and I am using a ListBox

  • 0

I have been working on a checklist application, and I am using a ListBox to display the data.
I am using arrays to populate the ListBox based on what button the user presses.
(I don’t know if that’s best practice but it works for now.) Once the user has completed the steps, he can remove the items with this command:

private void SendSelected()
{
    while (lstToDo.SelectedItems.Count > 0)
    {
        lstToDo.Items.Remove(lstToDo.SelectedItem);
    }
}

The problem is that today I have learned how to add CheckBoxes to my ItemTemplate with the xaml below:

<ListBox.ItemTemplate>
    <DataTemplate>
        <StackPanel Orientation="Horizontal">
            <CheckBox Padding="10">                            
                <CheckBox.LayoutTransform>
                    <ScaleTransform ScaleX="1" ScaleY="1" />
                </CheckBox.LayoutTransform>
            </CheckBox>
            <TextBlock Text="{Binding}"/>
        </StackPanel>
    </DataTemplate>
</ListBox.ItemTemplate>

Now the remove button still works… however I would like to adjust it so that it removes the checked items instead of selected items.
In winforms, I used to do it like this:

while (lstToDo.CheckedItems.Count > 0)
{
    lstToDo.Items.Remove(lstToDo.CheckedItems[0]);
}  

But in WPF, obviously this method doesn’t work, and I am just not sure why.

  • 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-17T09:42:19+00:00Added an answer on June 17, 2026 at 9:42 am

    you can bind the checkbox to the IsSelected property of the ListBoxItem

    <DataTemplate>
        <CheckBox Content="{Binding .}" IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected" />
    </DataTemplate>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a large java application. It is quite parallel, and
I have been working on an application for android that utilizes the android comparability
I have been working on a Django application lately, trying to get it to
I have been working on a website using MVC Preview 1 since it came
I have been working on a Notes integration project and I am using the
I have been working with a form in which I want the submit button
I have been working on a project that displays data in an XML file.
I have been working on a Qt application for some time now, and after
I have been working with the slider and am using the following code: $(function(){
I have been working on winforms using C# in my company for quite a

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.