Silverlight – ComboBox

Here is sample implementation of ComboBox in silverlight. it has the basic functionality. Ideally a Popup Control should be used in the controltemplate of the combobox. For some reason, it was not working when ItemsPresenter is added to Popup, will look into it

you can download the  source here

Advertisements

11 thoughts on “Silverlight – ComboBox

  1. Hi Lee,

    were you able to figure out the popup thing?

    thanks.

    p.s. thanks for sharing.. great way to learn looking at your code.

  2. If your ComboBox is built in a Silverlight Library Application and then I use it as a control in a Siverlight Application it doesn’t work.

    Can you help me this problem?

    Thanks! GoodLuck to you! 🙂

    Thao Nguyen

  3. Now, SL Beta 2 is released. When you create a new version of Combobox control. I have to complete my thesis, but if I change to SL beta 2 I don’t have combobox to use. Thanks! Hope here from you soon. 🙂

  4. I am getting exception, when I tried to convert. It doesnt give me any more details/line numbers other than the following

    System.CrossAppDomainMarshaledException was unhandled
    Message: System.NullReferenceException: Object reference not set to an instance of an object.
    at MS.Internal.Error.GetXresultForException(Exception ex)
    at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)

    I will post in the forum and see if someone will help me figure out what is going on

    As soon as I figure out what is going on, I will upload again

    Note: I am not sure when the final version of Silverlight is going to be released. but it will have a ComboBox natively from Microsoft

  5. I looked at it a bit and it looks like they changed the base template on you. In OnApplyTemplate you are looking for objects that aren’t found:
    _dropDownButton = GetTemplateChild(“ButtonElement”) as Button;
    _cp = GetTemplateChild(“ContentSite”) as ContentPresenter;

    _border = GetTemplateChild(“border”) as Border;

    These all return null. And ugliness follows..

    -Gary

  6. I closed and opened the project and Isaw the same error. I dont have a clue. may be I will write a blog post also while waiting for an answer in the forums

  7. hello! Trying to make it work with SL2B2.
    I get error on each
    new PropertyChangedCallback(OnIsSelectedChanged))
    I tried to change it to new PropertyMetaData(OnIsSelectedChanged)), compiles but it crashes… any idea?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s