2
我无法对此错误给出解释(VS 2017中的F#4.1)。F#在继承的构造函数参数列表中分配继承的属性值
公共代码:
open Eto.Forms
type MyCommand() as this =
inherit Eto.Forms.Command()
do
this.MenuText <- "C&lick Me, Command"
this.ToolBarText <- "Click Me"
this.ToolTip <- "This shows a dialog for no reason"
this.Shortcut <- Application.Instance.CommonModifier ||| Keys.M
下面的声明不是由F#编辑接受;在菜单初始化检测到的错误消息“命名的参数必须在所有其它参数之后出现”:
type MyForm1() =
inherit Eto.Forms.Form(
Title = "Eto Tests"
, ClientSize = Eto.Drawing.Size(600, 400)
, Menu = seq {yield new MyCommand()} |> Seq.fold (fun (mb:MenuBar) c -> mb.Items.Add(c) |> ignore; mb) (new MenuBar())
)
下面的声明没有工作,而不是错误:事先
type MyForm1() =
inherit Eto.Forms.Form(
Title = "Eto Tests"
, ClientSize = Eto.Drawing.Size(600, 400)
, Menu = let m = seq {yield new MyCommand()} |> Seq.fold (fun (mb:MenuBar) c -> mb.Items.Add(c) |> ignore; mb) (new MenuBar()) in m
)
感谢。
看起来像''let m = ... in ...''构造就像这里的一对圆括号一样工作。尝试在代码中使用“Menu =(seq {yield ...(new MenuBar()))”。 – dumetrulo