【问题标题】:The property "Class" does not exist in the namespace命名空间中不存在属性“类”
【发布时间】:2017-03-07 17:34:13
【问题描述】:

我对 WPF 很陌生,并且遇到了令人讨厌的错误消息。这是我的步骤:

  1. 在 Visual Studio 2015 中创建一个新的 WPF 应用程序。这是为 MainWindow 生成的默认 xaml(可以正常工作):

    <Window x:Class="Skype_Utility.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Skype_Utility"
        Title="MainWindow" Height="300" Width="300">
    
        <Grid>
        </Grid>
    </Window>
    
  2. 注意前两行:

    <Window x:Class="Skype_Utility.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    
  3. 接下来,我从here 获取了一些xaml,因为我正在尝试向项目中添加一个自动完成文本框:

    <Window x:Class="Skype_Utility.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml "
            xmlns:ac="clr-namespace:WpfAutoComplete.Controls;assembly=WpfAutoComplete" 
            Title="Autocomplete Text Box Project"  
            Height="300" Width="300"> 
    
        <Grid> 
    
            <StackPanel> 
    
                <Label Content="This is an Autocomplete Textbox" /> 
    
                <ac:TextBoxAutoComplete Name="autoTxtBoxEng" 
                    SearchDataProvider="{Binding Path=MySearchProviderEng}"  
                    SelectedListBoxValue="{Binding Path=PhraseNumber, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                    WatermarkText="Type in filtering text here..."/>  
    
            </StackPanel>
    
        </Grid>
    
    </Window>
    

但是,当我将他们的 xaml 放入我的项目时,我收到以下错误消息:

http://schemas.microsoft.com/winfx/2006/xaml”命名空间中不存在“类”属性。

即使这些行与默认代码中的行完全相同,并且没有给出错误...

即使它与自动生成的前几行字面上完全相同,Visual Studio 怎么能抱怨这条线?我不知道如何在这方面取得进展,非常感谢任何建议!

我对此的唯一想法是,在导致此问题的警告之后肯定有一些行,但在这种情况下,这是一个非常无用的错误消息!


由于存在错误,我无法构建或运行我的项目:

命名空间“clr-namespace:WpfAutoComplete.Controls;assembly=WpfAutoComplete”中不存在名称“TextBoxAutoComplete”。


http://schemas.microsoft.com/winfx/2006/xaml”命名空间中不存在“类”属性。


XML 命名空间“http://schemas.microsoft.com/winfx/2006/xaml”中不存在属性“类”。

【问题讨论】:

  • 它是否运行或者这是一个实际的编译器错误?
  • (通常视觉设计者有一些问题会导致甚至不存在的错误,并且应用程序仍然编译并运行)
  • 构建失败,由于错误,我也无法运行它。还显示了一些其他错误,我现在将添加到我的问题中
  • 其他错误可能是问题所在。它们还可能导致重影错误,因为在上一步构建失败。
  • @H.B.我添加了其他错误。我实际上设法通过添加对WpfAutoComplete 的引用来摆脱前两个,但它仍然抱怨Class 属性,这看起来很荒谬......

标签: c# wpf xaml visual-studio-2015 autocompletebox


【解决方案1】:

xmlns:x末尾的空格字符太多:

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml "

这样就变成了:

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

【讨论】:

  • @Bassie:没问题。
猜你喜欢
  • 1970-01-01
  • 2017-07-13
  • 1970-01-01
  • 2012-06-19
  • 1970-01-01
  • 2012-05-28
  • 1970-01-01
  • 1970-01-01
  • 2018-08-01
相关资源
最近更新 更多