I’m trying to create a custom WPF control and place it inside of a StackPanel in my XAML file. I originally made a custom UserControl and got the following error message:
A value of type 'CustomControl' cannot be added to a collection or dictionary of type 'UIElementCollection'.
I tried changing my custom control from a UserControl to a UIElement, but I still get this message. How do I make a custom control that I can place inside of the StackPanel?
How are you creating the CustomControl? Make sure it is inheriting from UserControl.
I just created a new project called “TestProj” – right clicked in the solution explorer Add=>UserControl and named it CustomControl.
I was able to insert it via the following code: