# User Controls and Dependency Properties - Article

**URL:** <https://forum.kirupa.com/t/user-controls-and-dependency-properties-article/245508>\
**Category:** programming\
**Created:** [November 30, 2007, 12:30pm UTC](https://forum.kirupa.com/t/user-controls-and-dependency-properties-article/245508 "2007-11-30T12:30:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaRoosTa](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@LaRoosTa](https://forum.kirupa.com/u/LaRoosTa)\
**Post date:** [November 30, 2007, 12:30pm UTC](https://forum.kirupa.com/t/user-controls-and-dependency-properties-article/245508/1 "2007-11-30T12:30:22Z")

</div>

Hi!

First of all, great article. I’m very new at C#, but I’m from a Flash background and this article has really helped me get into Blend.

However, I’m having difficulty trying to expose the ComboBox Items within a usercontrol and display it as a property for the UC.

EG. I have a Label and ComboBox inside a usercontrol.

So far I have this:

```auto

public ItemCollection ComboBoxContentUC
        {

            get
            {
                return (ItemCollection)GetValue(ComboBoxCollectionProperty);
            }
            set
            {
                SetValue(ComboBoxCollectionProperty, value);
            }

        }

        public static readonly DependencyProperty ComboBoxCollectionProperty =
            DependencyProperty.Register(
                "ComboBoxCollection",
                typeof(ItemCollection),
                typeof(CDSComboBox),
                new FrameworkPropertyMetadata(
                    new PropertyChangedCallback(ChangeComboBox)));

        private static void ChangeComboBox(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {

            (source as CDSComboBox).ComboBoxUC.Items.Add(e.NewValue as ItemCollection);

        }

```

The good thing that has come from this is that Blend is displaying “ComboBoxCollection(collection)” with an elipse button as a property in Miscellaneous section, which is allowing me to add Items. But as soon as I do the control gives the error: “Cannot create the instance of ItemCollection”

Thanks for a great article and in advance for your help.
