我通过XAML添加自定义控件时出现错误.可能的原因是什么? "..."类型的值无法添加到"uielementcollection"类型的集合或字典中
<Grid x:Name="QuantityDetail" DataContext="{StaticResource ViewModel}">
<GroupBox>
.....
<Label Style="{StaticResource ResourceKey=LabelValue}">Min</Label>
<!-- The following control -->
<NumericUpDow><NumericUpDown>
.....
</GroupBox>
</Grid>
Run Code Online (Sandbox Code Playgroud)
Mak*_*ect 17
问题是我没有在我的解决方案中引用一个dll(由numericupdown控件引用).实际上NumericUpDown控件不是我的控件,它存在于不同的dll中.这个控件引用了System.Windows.Controls.Input.Toolkit.dll.现在我在我的解决方案中引用它.事情正在发挥作用
我在我们的项目中也遇到了这个智能问题(构建仍然是可能的),但没有外部控制。所以也许有人需要这个答案......
这里的“问题”是,UserControlXYZ.xaml 被声明为 <UserControl> 但 UserControlXYZ.xaml.cs 没有从 UserControl 继承。所以我必须在 xaml.cs 中添加 UserControlXYZ :UserControl(即使 Resharper 说基本类型已经指定并且可以删除)。