Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Combobox.SelectedItem assignment not working when adding items statically

Combobox.SelectedItem assignment not working when adding items statically

Scheduled Pinned Locked Moved WPF
wpfwcfdesignhelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xtr33me
    wrote on last edited by
    #1

    I am having an issue and have scoured the net looking for an answer and I still have yet to find one so I thought I would post here while continuing my search. I simply want to set SelectedItem to a string value and have it select that item from the combobox. Now I am adding my items to the combobox statically during design time and when I do this, SelectedItem doesn't work and always is null. However I just found out that when I add my combobox items during runtime, selectedItem works just fine. Now I would like to know why this is. I am guessing that it is some binding that automatically happens when adding them dynamically, but I would love to know how to get this working statically. Thanks!

    M 1 Reply Last reply
    0
    • X xtr33me

      I am having an issue and have scoured the net looking for an answer and I still have yet to find one so I thought I would post here while continuing my search. I simply want to set SelectedItem to a string value and have it select that item from the combobox. Now I am adding my items to the combobox statically during design time and when I do this, SelectedItem doesn't work and always is null. However I just found out that when I add my combobox items during runtime, selectedItem works just fine. Now I would like to know why this is. I am guessing that it is some binding that automatically happens when adding them dynamically, but I would love to know how to get this working statically. Thanks!

      M Offline
      M Offline
      Michael Eber
      wrote on last edited by
      #2

      Please specify which version of the framework you are using. Assuming that this is a WPF application.

      X 1 Reply Last reply
      0
      • M Michael Eber

        Please specify which version of the framework you are using. Assuming that this is a WPF application.

        X Offline
        X Offline
        xtr33me
        wrote on last edited by
        #3

        Sorry this is WPF and I am working in VS2010 .Net 4.0.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups