【发布时间】:2016-08-01 17:05:53
【问题描述】:
我正在 Visual Studio 2015 中创建一个通用应用程序。我的通用应用程序引用了一个名为 UIComponents 的通用库。
在UIComponents我创建了一个用户控件:
namespace MyProj.UIComponents {
public sealed partial class MyControl : UserControl
{
public MyControl()
{
this.InitializeComponent();
}
}
}
使用以下 xaml:
<UserControl
x:Class="MyProj.UIComponents.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProj.UIComponents"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid>
<Rectangle Fill="White" HorizontalAlignment="Left" Height="280" Stroke="Black" VerticalAlignment="Top" Width="380" Margin="10,10,0,0"/>
<TextBox x:Name="textBox" Margin="20,20,20,20" TextWrapping="Wrap" Text="TextBox"/>
</Grid>
</UserControl>
在引用 UIComponents 的应用项目中,我这样做:
<Page
x:Class="MyProj.App.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProj.App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:MyProj.UIComponents"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ui:MyControl></ui:MyControl>
</Grid>
</Page>
但是当我尝试让设计器显示我得到的页面时:
错误列表显示如下:
名称空间中不存在名称“MyControl” “使用:MyProj.UIComponents”。
有趣的是,整个解决方案构建得很好,但设计师没有合作。
尝试使用clr-namespace
在 WPF 中有类似的问题,因此不是严格的通用应用程序,它们在解决方案使用的答案上标记为已解决:
xmlns:ui="clr-namespace:MyProj.UIComponents"
不起作用的Bu:
未定义的 CLR 命名空间。 'clr-namespace' URI 指的是命名空间 找不到“MyProj.UIComponents”。
【问题讨论】:
-
移动一点,你挡住了我们对错误列表的看法。
-
是的,抱歉忘记发布错误
-
类名是否为“MyProj.UIComponents.MyControl.MyControl”值得怀疑。所以它肯定应该是“使用:”MyProj.UIComponents” ..
-
我粘贴了错误的字符串抱歉,我已修复它
-
解释投票,否则人们无法理解他们做错了什么......
标签: c# .net visual-studio win-universal-app windows-10-universal