类型或命名空间名称'窗口'不存在命名空间存在'System.Windows“ [英] The type or namespace name 'Window' does not exist in the namespace 'System.Windows'

查看:594
本文介绍了类型或命名空间名称'窗口'不存在命名空间存在'System.Windows“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为WPF窗口类编写一个扩展方法。我在我的解决方案中的一个类库项目中做,所以我可以在解决方案中使用它在我所有的项目。



这里是我的代码:

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

命名空间ExtensionMethods
{
public static class MyExtensions
{
public static void ResizeToPrimaryScreenWorkingArea(this System.Windows.Window w)
{
}
}
}

,我得到以下错误:


类型或命名空间名称'Window'不存在于命名空间
'System中。 Windows'


是的,DID在我的类库项目中添加对System.Windows和System.Windows.Forms的引用,



我在做错了什么?

解决方案

添加 PresentationFramework.dll 引用到您的项目它包含 System.Windows 命名空间。 p>

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


I am trying to write an extension method for the WPF Window class. 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'

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.

What am I doing wrong?

解决方案

Add PresentationFramework.dll reference to your project it contains the System.Windows namespace.

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

这篇关于类型或命名空间名称'窗口'不存在命名空间存在'System.Windows“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆