【发布时间】:2013-01-24 07:54:31
【问题描述】:
我正在尝试将 x:Name 属性设置为 UserControl 的定义,以便稍后将其用于内部绑定:
<UserControl
x:Name="root"
x:Class="ElementManager.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
</UserControl>
它不会编译说:
类型名称“UserControl1”不存在于类型“ElementManager.ElementManager”中
如果我删除 x:Name 属性,它会编译并且一切正常。这是故意的还是我错过了一些微不足道的事情?
【问题讨论】:
-
你所做的通常是有效的。如果您从一个干净的项目开始,您可以自己检查。您的代码中一定还有其他一些您没有显示的故障。
-
这应该没问题,相关cs里还有其他代码吗?
标签: .net wpf xaml user-controls compiler-errors