无法设置X:名称="根和QUOT;在用户控件 [英] Can't set x:Name="Root" on UserControl
问题描述
我想设置x:Name属性到用户控件的定义,以后使用它内部的绑定:
I am trying to set the x:Name attribute to the definition of a UserControl to use it for internal bindings later on:
<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>
这并不编译说:
It doesn't compile saying:
类型名称的UserControl1'中不类型'ElementManager.ElementManager'存在
The type name 'UserControl1' does not exist in the type 'ElementManager.ElementManager'
如果我删除X:Name属性,编译和一切工作正常。那是不是意味着要还是我失去了一些小事?
If I remove the x:Name attribute, it compiles and everything works fine. Is this meant to be or am I missing something trivial?
推荐答案
该XAML的MSBuild任务是混淆你的类型 ElementManager
具有相同名称的命名空间。给你的类型 ElementManager
另一名比其周围的空间。
The XAML-MSBuild task is confusing your type ElementManager
with the namespace of the same name. Give your type ElementManager
another name than its surrounding namespace.
这篇关于无法设置X:名称=&QUOT;根和QUOT;在用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!