我正在尝试将 x:Name 属性设置为 UserControl 的定义,以便稍后将其用于内部绑定(bind):
<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>
它没有编译说:
The type name 'UserControl1' does not exist in the type 'ElementManager.ElementManager'
如果我删除 x:Name 属性,它会编译并且一切正常。这是故意的还是我错过了一些微不足道的事情?
最佳答案
XAML-MSBuild 任务混淆了您的类型 ElementManager
具有相同名称的命名空间。给你的类型ElementManager
与其周围的命名空间不同的名称。
关于.net - 无法设置 x :Name ="Root" on UserControl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14496353/