Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > ComboBox > SelectedItem not in ItemsSource

Not answered SelectedItem not in ItemsSource

Feed from this thread
  • MiddleTommy Intermediate avatar

    Posted on Jan 24, 2012 (permalink)

    Is it possible to have the SelectedItem of the Combobox be set and display correctly even if the item is not in the ItemsSource. I have had several scenarios where this would be usefull.

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Jan 27, 2012 (permalink)

    Hello Tommy,

    I am afraid this is not possible with the current implementation of the ComboBox. If you share your scenario in details with us, we might be able to suggest you a better approach for achieving this, if possible.

    All the best,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • MiddleTommy Intermediate avatar

    Posted on Jan 27, 2012 (permalink)

    I just read that Silverlight 5 adds similar behavior

    http://msdn.microsoft.com/en-us/library/hh397894(v=VS.95).aspx 
    "Prior to Silverlight 5, if you set the SelectedIndexSelectedItem, or SelectedValue before setting a Selector's ItemsSource, that value would be coerced to null. In Silverlight 5, the values stay set so there is selection when the ItemsSource is set. This enables a number of binding scenarios and matches the behavior in WPF. "

    I set the RadCombobox ItemsSource async. So it would be nice to have the RadComboBox follow this behavior. But actually show the value.

    Also I have scenarios where I am binding multiple sources to the same CurrentItem. But the combobox does not always have the current item

    Reply

  • Jonathan avatar

    Posted on Jan 27, 2012 (permalink)

    I agree this behavior would be much more preferable.

    As a workaround I have had to build a conditional binding markup extension.

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Feb 1, 2012 (permalink)

    Hello,

    The issue with the ComboBox is the following: when the ItemsSource is set, before all items are loaded, the SelectedValue will work only the first time, i.e. if the first item is not the searched one it will stop the search:

    var items = new ObservableCollection<DataItem>();
    combo.ItemsSource = items;
    foreach (var item in result)
    {
         items.Add(item);

    In order to make it work, it has to be set like this:

    var items = new ObservableCollection<DataItem>();
    foreach (var item in result)
    {
        items.Add(item);
    combo.ItemsSource = items;

    We are aware of this issue. However, we are still looking for a way to fix this without breaking the entire logic of the ComboBox and consequently all clients' project.

    Hope this information helps.

    Regards,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • MiddleTommy Intermediate avatar

    Posted on Feb 1, 2012 (permalink)

    It would also be much appreciated to add this behavior as well.

    var items = new ObservableCollection<DataItem>();
    items.Add(itemA);
    items.Add(itemB);
    items.Add(itemC);
    combo.ItemsSource = items;
    combo.SelectedItem = itemE;//Selected item will be shown as itemE but itemE will not be in the drop down.

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Feb 6, 2012 (permalink)

    Hi Tommy,

    I tested this behaviour with the ComboBox from the Toolkit, but seems that this behaviour is not available there also. So, I suppose once this is implemented there, we will be able to include it in RadComboBox as well.

    Regards,
    Konstantina
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > ComboBox > SelectedItem not in ItemsSource
Related resources for "SelectedItem not in ItemsSource"

Silverlight ComboBox Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]