User Controls and Dependency Properties - Article


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:

public ItemCollection ComboBoxContentUC

                return (ItemCollection)GetValue(ComboBoxCollectionProperty);
                SetValue(ComboBoxCollectionProperty, value);


        public static readonly DependencyProperty ComboBoxCollectionProperty =
                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.