无法在F# FSI中的WPF TextBox中输入文本

3
在下面的 F# WPF 代码中,当我从 F# FSI 中“显示”WPF 窗口时,无法在文本框中输入任何文本。这是否与使用 Windows Forms 事件循环有关?
let txtBox = new TextBox()
txtBox.BorderThickness <- Thickness(2.)
txtBox.Margin <- Thickness(7.)
txtBox.IsReadOnly <- false

let wnd = new Window(Title = "Test", Height = 500., Width = 500.)
wnd.Content <- txtBox
wnd.Show()

根据下面John Palmer的回答,我已经更新了上面的代码到正确版本。下面的代码现在可以在F# FSI中正常工作。
let txtBox = new TextBox()
txtBox.BorderThickness <- Thickness(2.)
txtBox.Margin <- Thickness(7.)
txtBox.IsReadOnly <- false

let wnd = new Window(Title = "Test", Height = 500., Width = 500.)
wnd.Content <- txtBox

(new Application()).Run(wnd) |> ignore
1个回答

5
你需要调用 Application.Run - 参见 这里。这将自动为你启动事件循环。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接