【问题标题】:"properties" is not defined?“属性”没有定义?
【发布时间】:2013-01-04 03:45:37
【问题描述】:

我正在尝试按照本教程进行用户设置:

http://blogs.msdn.com/b/patrickdanino/archive/2008/07/23/user-settings-in-wpf.aspx

我定义了一个名称为 Selected、type int、scope user 的设置。在 App.xaml 中,我有:

<Application.Resources>
        <properties:Selected x:Key="Selected"/>
    </Application.Resources>

但是我收到了这个错误信息:

“命名空间前缀“properties”未定义”

我不知道为什么...欢迎任何建议。

PS。如果你能看看我的另一个问题,那就太好了! :)

Cannot find source for binding

编辑: 解决了!

【问题讨论】:

  • App.xaml 的其余部分是什么样的?该错误表明 Application 标记中没有像 xmlns:properties="clr-namespace:SampleApp.Properties" 这样的命名空间声明。

标签: c# wpf


【解决方案1】:

您需要确保在某处定义了属性命名空间,如您链接的示例所示:

<Application x:Class="SampleApp.App"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:properties="clr-namespace:SampleApp.Properties"
   Exit="OnExit"
   StartupUri="MainWindow.xaml">
     <Application.Resources>
         <properties:Settings x:Key="Settings" />
     </Application.Resources>
</Application>

注意这一行:xmlns:properties="clr-namespace:SampleApp.Properties"

您可能需要在此错误消失之前重新编译。

【讨论】:

    猜你喜欢
    • 2021-08-03
    • 2014-11-14
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2021-10-17
    • 2019-08-07
    • 2017-04-13
    • 1970-01-01
    相关资源
    最近更新 更多