简体   繁体   English

如何在F#源文件中继承Window类

[英]How can I inherit the Window class in a F# source file

When scripting it's done like: 编写脚本时,其操作如下:

#light 
#r "System.Xaml.dll"
#r "WindowsBase.dll"
#r "PresentationCore.dll"
#r "PresentationFramework.dll"

open System
open System.Windows

let win = new Window()
win.Title <- "Say Hello"
win.Show()

#if COMPILED
[<STAThread()>]
do 
    let app =  new Application() in
    app.Run() |> ignore
#endif

Beneath text for a source file, where I've added System.Xaml, WindowsBase, PresentationCore and PresentationFramework to my references. 在源文件的文本下方,在该文件中,我已将System.Xaml,WindowsBase,PresentationCore和PresentationFramework添加到我的引用中。

open System
open System.Windows

let win = new Window()
win.Title <- "Say Hello"
win.Show()

#if COMPILED
[<STAThread()>]
do 
    let app =  new Application() in
    app.Run() |> ignore
#endif

I get the message: The type "Window" is not defined. 我收到消息:未定义类型“窗口”。 Can anybody tell me how to acces / reference the namespaces System.Windows and System.Windows.Controls from a source file? 有人可以告诉我如何从源文件访问/引用名称空间System.Windows和System.Windows.Controls吗?

Thanks 谢谢

EDIT: Added screenshot 编辑:添加了屏幕截图

Before going any further I want to turn the script (with UI) into a source file. 在继续之前,我想将脚本(带有UI)转换为源文件。

错误:未定义类型“窗口”

  1. In Solution Explorer, select the project. 在解决方案资源管理器中,选择项目。 On the Project menu, click Add Reference. 在项目菜单上,单击添加引用。 Or: Project -> Add Reference 或者:项目->添加参考

  2. The Add Reference dialog box opens. 将打开“添加引用”对话框。 Select the tab indicating the type of component you want to reference. 选择指示您要引用的组件类型的选项卡。

Choose: 选择:

WindowsBase.dll
PresentationCore.dll
PresentationFramework.dll
System.Xaml.dll

Or download template: 或下载模板:

https://visualstudiogallery.msdn.microsoft.com:443/e0907c99-bb04-4eb8-9692-9333d5ff4399 https://visualstudiogallery.msdn.microsoft.com:443/e0907c99-bb04-4eb8-9692-9333d5ff4399

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

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