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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:54:14+00:00 2026-05-19T04:54:14+00:00

(Please note – I am a Silverlight beginner and am looking for the simplest

  • 0

(Please note – I am a Silverlight beginner and am looking for the simplest solution here, e.g. that doesn’t involve writing/installing a replacement for the ComboBox control!)

This is an issue with a Silverlight 4 application that uses the View Model (MVVM) approach. I have a simple form for editing a “Product” object. Product has a CategoryID property which is nullable (int?). A ComboBox is used to view and set the CategoryID – this is bound to an ObservableCollection of Categories. Product also has number of non-nullable properties bound to TextBoxes.

I want the user to see “N/A” in the ComboBox for a product with no category, and to be use this “N/A” option to set CategoryID to null. So, I manually added a Category object with CategoryID=0 and CategoryName=”N/A” to the collection; then I set TargetNullValue=0 in the SelectedValue Binding of the ComboBox. My thinking was – when the ComboBox SelectedValue was bound to a null CategoryID it would substitute zero, and therefore select the “N/A” option.

When editing a Product with a non-null CategoryID, everything works. However when a null CategoryID is found, two problems occur:

  1. No option is selected in the ComboBox (its blank)

  2. The ComboBox binding seems broken from this point onwards – any Product I subsequently edit (incl. ones with a non-null CategoryID) have nothing selected in the ComboBox (its still populated with all categories – just no selected item).

I’ve seen reports of problem #2 (here, here) but I was under the impression that #1 should have worked.

What am I missing to get the “N/A” option to be selected?

XAML for ComboBox:

<ComboBox x:Name="cboCategory" ItemsSource="{Binding colCategories, Mode=OneWay}" SelectedValuePath="CategoryID" DisplayMemberPath="CategoryName" SelectedValue="{Binding CurrentProduct.CategoryID, Mode=TwoWay, TargetNullValue=0}" Height="24" Width="344"></ComboBox>
  • 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-19T04:54:14+00:00Added an answer on May 19, 2026 at 4:54 am

    I ended up using a Converter that converts the Null in the bound object to zero in the ComboBox and then back again … like the one mentioned here http://forums.silverlight.net/forums/t/195627.aspx

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

Sidebar

Related Questions

please note that I'm a complete beginner to Qt development. I have a QWebView
Please note the Edit below for a lot more information, and a possible solution
Please note - I am not looking for the right way to open/read a
Please note that I already know of and understand the ABA problem . This
Please note that this question is intended to be a bit more on the
[Please note that this is a different question from the already answered How to
Please note that this is asking a question about constructors, not about classes which
Please note that Object.Watch and Object.Observe are both deprecated now (as of Jun 2018).
How can we consume WCF service in .Net 2.0 Winform. Please note that we
Please note that this question is about CGLayer (which you typically use to draw

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.