WPF C# Properties.Settings 不存在

WPF C# Properties.Settings doesn't exist

我正在尝试为我的 WPF 应用程序创建简单的 application/user 设置。

大多数答案和教程建议为此使用 Properties.Settings.Default
但是,Settings 在我的 Properties 命名空间中不存在。
我的项目资源管理器中也没有 .settings 文件,正如 the microsoft documentation 建议的那样:

  1. Open Visual Studio.
  2. In Solution Explorer, expand the Properties node of your project.
  3. Double-click the .settings file in which you want to add a new setting. The default name for this file is Settings.settings.

我的项目属性 window 中也没有 设置 选项卡,正如某些(较旧的?)资源所建议的那样。

WPF App (.NET Core) 模板默认情况下似乎没有添加 .settings 文件,这与 WPF App (.NET Framework) 不同。

您可以通过右键单击您的项目文件 -> 添加 -> 新项目... -> 设置文件来添加它(您可以搜索它,或者在 Visual C# -> 常规下浏览)。

查看此答案:

看起来您使用的是 .NET Core 而不是 .NET Framework 和 WPF。右键单击您的 MyApp 项目并添加一个名为“Properties”的新文件夹。然后右键单击它并添加一个新项目。搜索设置,添加设置文件。他们你应该可以使用这个。

我在我的项目属性视图中没有看到设置选项卡,但是如果您右键单击设置文件,您可以将 Open with 更改为旧视图的设置设计器。