简体   繁体   English

命名空间“System.Windows”中不存在类型或命名空间名称“Window”

[英]The type or namespace name 'Window' does not exist in the namespace 'System.Windows'

I am trying to write an extension method for the WPF Window class.我正在尝试为 WPF Window 类编写扩展方法。 I am doing it in a class library project in my solution, so that I can use it in all my projects in the solution.我在我的解决方案中的类库项目中执行此操作,以便我可以在解决方案中的所有项目中使用它。

Here is my code:这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace ExtensionMethods
{
    public static class MyExtensions
    {
        public static void ResizeToPrimaryScreenWorkingArea(this System.Windows.Window w)
        { 
        }
    }
}

When I try to compile this, I get the following error:当我尝试编译它时,出现以下错误:

The type or namespace name 'Window' does not exist in the namespace 'System.Windows'命名空间“System.Windows”中不存在类型或命名空间名称“Window”

Yes, I DID add references to System.Windows and System.Windows.Forms in my class library project, and they are showing under References in the project in Solution Explorer.是的,我确实在我的类库项目中添加了对 System.Windows 和 System.Windows.Forms 的引用,它们显示在解决方案资源管理器中项目中的引用下。

What am I doing wrong?我究竟做错了什么?

Add PresentationFramework.dll reference to your project it contains the System.Windows namespace.向包含System.Windows命名空间的项目添加PresentationFramework.dll引用。

http://msdn.microsoft.com/es-es/library/system.windows.window(v=vs.110).aspx http://msdn.microsoft.com/es-es/library/system.windows.window(v=vs.110).aspx

暂无
暂无

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

相关问题 命名空间“System.Windows”中不存在类型或命名空间名称“部署” - The type or namespace name 'Deployment' does not exist in the namespace 'System.Windows' 命名空间“System.Windows”中不存在类型或命名空间名称“Forms” - The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' WPF类型或名称空间名称“浏览器”在名称空间“ System.Windows”中不存在(您是否缺少程序集引用?) - WPF The type or namespace name 'Browser' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) 命名空间系统中不存在“表单”。windows - 'Forms' does not exist in the namespace system.windows 使用 mcs 编译器在 linux 中编译 c# 时出现错误:命名空间“System.Windows”中不存在类型或命名空间名称“Forms”? - Compiling c# in linux using mcs compiler gives error : The type or namespace name `Forms' does not exist in the namespace `System.Windows'? 命名空间 system.windows 中不存在 VS2022 'Forms' - VS2022 'Forms' does not exist in the namespace system.windows 命名空间“System”中不存在类型或命名空间名称“Windows” - The type or namespace name 'Windows' does not exist in the namespace 'System' 类型或命名空间名称“ DataGridViewDataErrorEventHandlerArgs”在“ System.Windows.Forms”中不存在 - The Type or Namespace name 'DataGridViewDataErrorEventHandlerArgs' does not exist in 'System.Windows.Forms' 在类库错误中填充Combobox:'控件'在命名空间'System.Windows'中不存在于WPF项目中 - populating a Combobox in class library error :'Controls' does not exist in the namespace 'System.Windows' works in WPF project 类型或名称空间名称“ SQLite”在名称空间“ System.Data”中不存在 - The type or namespace name 'SQLite' does not exist in the namespace 'System.Data'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM