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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:19:52+00:00 2026-05-26T03:19:52+00:00

I have a list box bound to an ObservableDictionary (custom class, left out for

  • 0

I have a list box bound to an ObservableDictionary (custom class, left out for brevity) class. And it is working great except for the binding on the SelectedItem. I have the following property bound to the selectedItem of the ListBox.

public KeyValuePair<Bumpstop, BumpStopOptions> SelectedBumpstop
    {
        get
        {
            return this.selectedBumpstop;
        }
        set
        {
            this.selectedBumpstop = value;
            this.OnPropertyChanged("SelectedBumpstop");
        }
    }

When I select an item in my list box it hits the set property and it works. When I unselect everything the ListBox gets the RedBorder around it indicating a binding failure and it does not set the SelectedBumpstop property to null like I would expect. Why does it not set it to null?

  • 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-26T03:19:52+00:00Added an answer on May 26, 2026 at 3:19 am

    Red border is not a binding failure (in the sense of binding errors found in the VS Output box), it is a validation failure.

    The bindings automatically check if the new value is acceptable for the binding source type (in this case the KeyValuePair). No value selected would mean null as selected value, which is not valid for KeyValuePair – it is a structure, which are value types, therefore can’t posess a null value. So the validation fails and the value is not uploaded to the source.

    Making the type nullable (KeyValuePair<Bumpstop, BumpStopOptions>?) will fix this, but it can have ramifications for your other code, so think this through carefully (you may have to add nullity checks wherever the property is used).

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

Sidebar

Related Questions

I have a XAML view with a list box: <control:ListBoxScroll ItemSource={Binding Path=FooCollection} SelectedItem={Binding SelectedFoo,
Setup: I have a combo-box, it's itemsource bound to an ObservableCollection<T> of a custom
I am working on a project and I want to have a list box
I have a list of links bound to a fairly narrow box; narrow enough
I have a ListBox bound to a list of Items (for arguement, lets say
I have a ListBox that is bound to a list of Persons. I want
So, I have a ListBox which is bound to a list of business objects,
I have a list box control: <asp:ListBox runat=server id=lbox autoPostBack=true /> The code behind
I have a ComboBox that is bound to an ObservableCollection of custom UserControls. Each
Here are my requirements: I have a dropdown list and text box (appName and

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.