XAML设计师拒绝接受用户控制(XAML designer refuses to accept user control)
XAML设计者要么抱怨控件不在名称空间中,要么控件可以放在UIElement集合中。
该控件的定义如下:
namespace OdinSyncManager.Controls { public partial class ServiceListItem: UserControl { public ServiceListItem() { InitializeComponent(); } } }XAML具有以下代码(我只将文件头部包含在控件中):
<... xmlns:Control="clr-namespace:OdinSyncManager.Controls" mc:Ignorable="d" Title="MainWindow"> <DockPanel LastChildFill="True" Margin="0,0,14,14" Background="#FFFF6D6D"> <Control:ServiceListItem/> <...>我不确定缺少什么?
The XAML designer either complains that the control isn't in the namespace or that the control can be placed in a UIElement Collection.
The control is defined as such:
namespace OdinSyncManager.Controls { public partial class ServiceListItem: UserControl { public ServiceListItem() { InitializeComponent(); } } }The XAML has the following code (I've only included the head of the file up to the control):
<... xmlns:Control="clr-namespace:OdinSyncManager.Controls" mc:Ignorable="d" Title="MainWindow"> <DockPanel LastChildFill="True" Margin="0,0,14,14" Background="#FFFF6D6D"> <Control:ServiceListItem/> <...>I'm not sure what's missing?
最满意答案
确保你添加了一个WPF UserControl到你的项目中,而不是一个winform
Make sure you added a WPF UserControl to your project, not a winform
更多推荐
发布评论