无法使用已实现的命名空间 System.Windows [英] Can't use implemented namespace System.Windows
问题描述
我有一个带有上下文菜单的 UserControl,当用户单击上下文菜单中的项目时,我想让另一个用户对话框弹出.我设计了一个用户对话框并搜索了一种让它弹出的方法.我找到了简单的变体:
I have a UserControl with a context menu, when the user clicks on an item in the context menu I want to let another user dialog pop up. I designed a user dialog and searched for a method to let it pop up. I found the easy variant with:
Window myWindow = new Window { Title = "myTitle".. };
然后
myWindow.ShowDialog();
然后我实现了对 System.Windows 的引用并使用了这一行:
Then I implemented the reference to System.Windows and used the line:
using System.Windows;
但是当我尝试在 Visual Studio 上方编写我的代码时,说找不到类型或命名空间.我知道可能有一个简单的解决方案,但目前我找不到.
But when I try to write my Code above Visual studio says type or namespace not found. I know that there could be an easy solution, but at the moment I can't find it.
一段时间后,它起作用了.但只是因为 Visual Studio 告诉我命名空间不清楚.我必须写清楚 System.Windows
After some time it worked. But only because Visual studio told me that the namespace is unclear. I had to write clearly System.Windows
但最后我不知道为什么 Visual Studio 一开始就告诉我这个,或者为什么它从一开始就不起作用.
But in the end I didn't know why Visual Studio told me this in the beginning, or why It didn't work from the beginning.
推荐答案
对于对话框,你需要包括:
For dialogs, you need to include:
using System.Windows.Forms;
希望这会有所帮助.
这篇关于无法使用已实现的命名空间 System.Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!