简体   繁体   English

vb.net WPF窗口类需要导入吗?

[英]vb.net Imports needed for WPF Window class?

I have a class library with extension methods and I'm trying to write an extension method that works with a Window class, from a WPF app. 我有一个带有扩展方法的类库,我正试图从WPF应用程序编写一个与Window类一起使用的扩展方法。

When I try writing the extension to accept a parameter of type Window, I get an error that this type can't be found; 当我尝试编写扩展以接受Window类型的参数时,出现一个错误,指出找不到该类型。

I can't seem to find an assembly to import that will resolve this error, so I thought I'd post it here to see if I'm doing something wrong. 我似乎找不到要解决此错误的要导入的程序集,因此我想将其发布在此处以查看是否做错了什么。

As an example, here's a simple extension I'd like to be able to use: 例如,这是我想使用的一个简单扩展:

    <Extension>
    Public Sub helloworld(window As System.Windows.Window) 'Error- type system.windows.window is not defined

        ...

    End Sub

But I'm getting the error that the type system.windows.window is not defined. 但是我得到的错误是未定义类型system.windows.window。

I've even tried adding a reference to this class library to the System.Windows assembly, and adding an imports at the top of the screen, but it doesn't help. 我什至尝试将对此类库的引用添加到System.Windows程序集中,并在屏幕顶​​部添加导入,但这无济于事。

I ended up taking a look at the references used on a normal WPF app project, and realized that there's a reference to PresentationFramework.... which is verbiage similar to...Windows Presentation Framework (WPF) ;) 最后,我看了普通WPF应用程序项目上使用的引用,并意识到存在对PresentationFramework ....的引用,这与... Windows Presentation Framework(WPF)相似。

I added this reference to my class library, and suddenly everything just worked. 我将此引用添加到我的类库中,突然一切正常。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM