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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:22:06+00:00 2026-05-15T22:22:06+00:00

If i have a Collection bound to n togglebuttons in a stackpanel in a

  • 0

If i have a Collection bound to n togglebuttons in a stackpanel in a usercontrol….how can I update the underlying Collection with no code behind (including Checked and unchecked events) and complete update logic?

Thanks,

U.

  • 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-15T22:22:07+00:00Added an answer on May 15, 2026 at 10:22 pm

    Your question is vague, but I appreciate why that is (commercial stuff). We can therefore only guess at what the problem may be.

    I’ll try my best…

    It sounds like you want seven ToggleButtons, each button activating/deactivating a day of the week. You have a collection of 7 Boolean values. Each ToggleButton’s IsChecked property is bound to a Boolean in the collection.

    The problem is that at the moment, you are trying to change the object in the collection, rather than just a property of that object. I don’t know if straight swapping of items at certain positions is supported my ObservableCollection or not, but it’s certainly possible that the WPF binding framework does not support straight swaps of objects in collections. You can add and remove items, but not do straight swaps at certain positions.

    You can however work around this (possible) limitation.

    Try creating a new class which implements INotifyPropertyChanged like so:

    class BooleanWrapper : INotifyPropertyChanged
    {
      private Boolean isSelected;
      public Boolean IsSelected
      { 
        get { return isSelected; }
        set
        {
          if (isSelected != value)
          {
            isSelected = value;
            // TODO: Raise PropertyChanged event.
          }
        }
      }
    }
    

    (If you’re not familiar with INotifyPropertyChanged it’s pretty simple – there are plenty examples on MSDN. It allows the binding framework to detect property changes)

    Instead of having an ObservableCollection<Boolean>, have an ObservableCollection<BooleanWrapper>. Each ToggleButton’s IsChecked property should be bound to the BooleanWrapper’s IsSelected property.

    Now you’re not trying to swap objects in and out of the collection, you’re just updating the value of a property of an object within the collection.

    As a side note, if you’re only binding to days of the week, in my opinion there’s nothing wrong with binding to a class like:

    class DaySelection : INotifyPropertyChanged
    {
      public Boolean IsMondaySelected { ... }
      public Boolean IsTuesdaySelected { ... }
      ...
    }
    

    which should give you no problems, but that’s up to you, and I may have made errors in my psychic requirements capture – please ignore if it’s not relevant to what you want.

    I hope I’ve made some sense!

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

Sidebar

Related Questions

I have set up a grid and bound it to a collection. I can
I have a ComboBox bound to a collection of objects defined as this. public
I have a DataGrid in WPF bound to an observable collection. In my UI
I have a treeview that is bound to a collection and each item in
I have an ItemsControl that is bound to a collection of objects. Each object
I have a WPF ItemsControl who's ItemsSource is bound to an observable collection of
I have a ListView whose ItemsSource is bound to an ObservableCollection. The collection is
I have an observable collection bound to a listbox in WPF. One of the
I have a scenario where I have a collection of objects bound to a
I have a collection of objects stored in a CollectionViewSource and bound to 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.