C# WPF 项目中缺少“位图”命名空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31635193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Missing "Bitmap" namespace in C# WPF project
提问by DarkMisha
I need to use "Bitmap" from namespace "System.Drawing" but there is nothing like this . If I create "Windows forms Application" there is not a problem like this.
我需要使用命名空间“System.Drawing”中的“Bitmap”,但没有这样的东西。如果我创建“Windows 窗体应用程序”,就不会有这样的问题。
How to use this "Bitmap" in my WPF project (add namespace that contains Bitmap class)? I use Microsoft Visual Studio 2015 RC.
如何在我的 WPF 项目中使用这个“位图”(添加包含位图类的命名空间)?我使用 Microsoft Visual Studio 2015 RC。
回答by Bahman_Aries
This is my problem. System.Drawing not contain "Bitmap" namespace in WPF project, but when i create Windows Forms application there is Bitmap.
这是我的问题。System.Drawing 在 WPF 项目中不包含“位图”命名空间,但是当我创建 Windows 窗体应用程序时,有位图。
This is because WinForm has a reference to System.Drawingby default but WFP doesn't. So you need to add this reference manually (right-click on Solution Explorer -> References -> Add Reference ... ).
这是因为System.Drawing默认情况下WinForm 有一个引用,但 WFP 没有。因此您需要手动添加此引用(右键单击解决方案资源管理器 -> 引用 -> 添加引用...)。
回答by DeshDeep Singh
Look at this information: namespace to use in your class file is System.Drawing and refrence that you need to have is System.Drawing .
看看这个信息:在你的类文件中使用的命名空间是 System.Drawing ,你需要的参考是 System.Drawing 。
Namespace: System.Drawing Assembly: System.Drawing (in System.Drawing.dll)
命名空间:System.Drawing 程序集:System.Drawing(在 System.Drawing.dll 中)

