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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:35:09+00:00 2026-05-29T12:35:09+00:00

I need to dynamically generate some combo boxes on a silverlight page. If I

  • 0

I need to dynamically generate some combo boxes on a silverlight page.

If I have the following xaml:

<ComboBox Name="Combo1">
  <ComboBox.Items>
    <ComboBoxItem Name="Option1" Content="Option 1" />
    <ComboBoxItem Name="Option2" Content="Option 2" />
  </ComboBox.Items>
</ComboBox>
<ComboBox Name="Combo2">
  <ComboBox.Items>
    <ComboBoxItem Name="Option1" Content="Option 1" />
    <ComboBoxItem Name="Option2" Content="Option 2" />
  </ComboBox.Items>
</ComboBox>

I get errors saying that the second Option1 name (under Combo2) already exists in the namespace.

I’ve read here that this is a bug in silverlight, but I couldn’t quite understand how to get around it. I need to be able to retrieve the string Option1 from the selected ComboBox item.

Any ideas?

EDIT: I have a custom control that generates some combo boxes. Some sample XAML code would look like this:

<ComboBox Name="Combo1">
  <ComboBox.Items>
    <ComboBoxItem Name="True" Content="Yes" />
    <ComboBoxItem Name="False" Content="No" />
  </ComboBox.Items>
</ComboBox>
<ComboBox Name="Combo2">
  <ComboBox.Items>
    <ComboBoxItem Name="True" Content="Okay" />
    <ComboBoxItem Name="False" Content="Not Okay" />
  </ComboBox.Items>
</ComboBox>

I want to be able to retrieve the selected ComboBoxItem “Name”, not the “Content”.. However, doing it like this, I will run into errors if any comboboxitem “Name” is not unique (in this control).

  • 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-29T12:35:10+00:00Added an answer on May 29, 2026 at 12:35 pm

    You cannot use the same name twice in an XAML/Class file. If you want to dynamically generate a custom combobox, then create a template and use that to dynamically generate the custom combobox or create a custom control that implement combobox.

    When doing things like <ComboBoxItem/> in the xaml, it’s actually calling the constructor of ComboBoxItem to create a ComboBoxItem object. By giving it a name, you can use that to reference the object in behind-code. So imagine if you have two objects with the same name in the behind-code within the same class….the compiler wouldn’t allow you to do that.

    The link that you referenced is a bug because you should be able to have the same name if the objects are in separate classes, so there shouldn’t be any naming conflict. But in your case, it seems like you’re trying to create two objects with the same name within the same class.

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

Sidebar

Related Questions

I need to dynamically generate radio or checkbox by jQuery. I use the following
I have an empty JTable, absolutely nothing in it. I need to dynamically generate
I need to dynamically generate some macros into a .h configuration file that C
I'm doing some metaprogramming in Ruby, and I need to dynamically generate a sibling
I need to dynamically generate and execute some javascript on change of a select
I have some ASP.NET MVC actions that generate images dynamically (although it could equally
I have a series of dynamically generated inputs that I need to have ajax
I have a grid and I need to dynamically replace a control that resides
I have a GridView that I need to dynamically add TemplateField elements to. My
I need to do some modifications on dynamically generated strings; String Example Products [279]

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.