簡體   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