如何在f#源文件中继承窗口类?

时间:2021-12-09 13:34:07

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.

在源文件的文本下面,我添加了系统。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。来自源文件的控件?

Thanks

谢谢

EDIT: Added screenshot

编辑:添加截图

Before going any further I want to turn the script (with UI) into a source file.

在进一步讨论之前,我希望将脚本(与UI)转换为一个源文件。

如何在f#源文件中继承窗口类?

1 个解决方案

#1


0  

  1. In Solution Explorer, select the project. On the Project menu, click Add Reference. Or: Project -> Add Reference

    在“解决方案资源管理器”中,选择项目。在“项目”菜单上,单击“添加引用”。或者:Project ->添加引用。

  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 4 - eb8 - 9692 - 9333 - d5ff4399

#1


0  

  1. In Solution Explorer, select the project. On the Project menu, click Add Reference. Or: Project -> Add Reference

    在“解决方案资源管理器”中,选择项目。在“项目”菜单上,单击“添加引用”。或者:Project ->添加引用。

  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 4 - eb8 - 9692 - 9333 - d5ff4399