Search code examples
c#wpfxaml

A value of type '...' cannot be added to a collection or dictionary of type 'UIElementCollection'


I am getting the following error when I am adding a custom control via XAML. What can be the possible reason?

A value of type '...' cannot be added to a collection or dictionary of type 'UIElementCollection'

<Grid x:Name="QuantityDetail" DataContext="{StaticResource ViewModel}">
    <GroupBox>
       .....
       <Label Style="{StaticResource ResourceKey=LabelValue}">Min</Label>
       <!-- The following control -->
       <NumericUpDown></NumericUpDown>
       .....
    </GroupBox>
</Grid>
           

Solution

  • Problem was that I was not referencing to one DLL (which is referenced by NumericUpDown control) in my solution. Actually NumericUpDown control is not my control, it is present in a different DLL. And this control was refering System.Windows.Controls.Input.Toolkit.dll. Now I am refering it in my solution and things are working.