开发者

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="{StaticResour开发者_开发技巧ce ResourceKey=LabelValue}">Min</Label>
       <!-- The following control -->
       <NumericUpDown></NumericUpDown>
       .....
    </GroupBox>
</Grid>
           


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, its present in different dll. And this control was refereing System.Windows.Controls.Input.Toolkit.dll. Now I am refereing it in my solution. And things are working


I had this intellise problem as well in our project (building was still possible), but not with an extern control. So maybe someone needs this answer...

The "problem" here was, that the UserControlXYZ.xaml was declared as but the UserControlXYZ.xaml.cs did not inherit from UserControl. So I had to add the UserControlXYZ :UserControl in xaml.cs (even though Resharper says base type is already specified and can be removed).


The compiler claims that your control is not an UIElement (i doubt that it is lying), what does your control inherit from?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜