繁体   English   中英

Xaml编译器和设计器以不同的方式处理clr-namespace

[英]Xaml compiler and designer treating clr-namespace differently

我有一个非常简单的wpf应用程序,用于演示我构建的类库,但是我遇到了一些奇怪的问题:

xmlns:lcl="clr-namespace:testApp;assembly=testApp"

以上是重要的一行,但我将包括所有要完成的内容。

<Window x:Class="testApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:lcl="clr-namespace:testApp;assembly=testApp"
        xmlns:evt="clr-namespace:EventToCommand;assembly=EventToCommand"
        Title="MainWindow" Height="350" Width="525">
    <Window.DataContext>
        <lcl:ViewModel />
    </Window.DataContext>
    <Label Name="lblOutput" VerticalAlignment="Center" HorizontalAlignment="Center" Content="{Binding labelOutput}" />
</Window>

当我包括该程序集时,设计器将工作,并且标签文本上的绑定将正常工作。 但是,当我构建并运行程序时,出现以下错误:

Error   1   The tag 'ViewModel' does not exist in XML namespace 'clr-namespace:testApp;assembly=testApp'

当我删除该行的装配部分时,设计师将停止向我展示任何东西,但是该程序可以正常构建和运行。

发生了什么事,我该如何阻止它?

编辑:

这是AssemblyInfo.cs文件的顶部,以显示这是正确的名称:

[assembly: AssemblyTitle("testApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("testApp")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

尝试将参考xmlns:lcl =“ clr-namespace:testApp; assembly = testApp”更改为xmlns:lcl =“ clr-namespace:testApp”

当类在同一项目视图中时,不必使用“ assembly =”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM