none
ComboBox - Refresh RRS feed

  • Question

  • I sometimes find when adding items  to a ComboBox,  both the box that appears under the ComboBox does not have it's edge clearly defined, and items added do not appear as I add them.

    How to I force a refresh? UpdateLayout and InvalidateArrange do not sort this problem out.
    Friday, December 7, 2007 1:25 PM

Answers

  • I meant Visual Studio 2008 RTM. I tried adding items to a combobox in exactly the way you have, and it works fine in VS 2008 RTM - I don't have VS2005 installer here.

     

    Have you ever installed Visual Studio 2008 Beta 2 or a .Net 3.5 Beta? (sorry to go on about it, but it sounds exactly like that bug)

     

    Nick.

    Friday, December 7, 2007 7:12 PM

All replies

  • How are you adding items to ComboBox? If you've assigned a collection to ItemsSource, it need to implement INotiftyCollectionChanged, which in practice means your collection should be ObservableCollection<T>.

     

    the box that appears under the ComboBox does not have it's edge clearly defined

     

    Try setting <ComboBox ... SnapsToDevicePixels="true" ... />

     

    Regards,

    Nick.

    Friday, December 7, 2007 2:41 PM
  • comboBox1.Items.Add("test" + Convert.ToString(comboBox1.Items.Count));


    Adding SpansToDevicePixels makes no difference.
    What I notice however, the first time I click the drop down to expand the list, the list is not correct, but the second time I click to expand, it is.
    There is something being updated as a result of the the first expansion or list being closed?

    Friday, December 7, 2007 2:52 PM
  • I find that by adding the following immediately after adding a series of values, the dropdown appears fine when I click the dropdown button:

                comboBox1.IsDropDownOpen = true;
                comboBox1.IsDropDownOpen = false;


    This is a kludgy workaround; surely there has to be a more elegant way of getting the drop down the right size?
    Friday, December 7, 2007 3:20 PM
  • OK, this all sounds like the Popup bug in Visual Studio 2008 Beta 2. Is that what you are using? Try it on the RTM bits, it will probably all work fine.

     

    Regards,

    Nick.

    Friday, December 7, 2007 6:20 PM
  • Visual Studio 2005 .
    RTM bits? What are they?
    Friday, December 7, 2007 6:59 PM
  • I meant Visual Studio 2008 RTM. I tried adding items to a combobox in exactly the way you have, and it works fine in VS 2008 RTM - I don't have VS2005 installer here.

     

    Have you ever installed Visual Studio 2008 Beta 2 or a .Net 3.5 Beta? (sorry to go on about it, but it sounds exactly like that bug)

     

    Nick.

    Friday, December 7, 2007 7:12 PM
  • I've written WPF code under .NET Framework 3.0 for a while, and if I remember correctly, I never encountered such a problem. This problem can occur under .NET Framework 3.5 Beta2, and it's been fixed in the RTM bit.

    Hope this helps
    Wednesday, December 12, 2007 9:37 AM