无法在F#FSI的WPF文本框中输入文本 [英] Unable to enter text in WPF TextBox in F# FSI
本文介绍了无法在F#FSI的WPF文本框中输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的F#WPF代码中,当我从F#FSI显示" WPF窗口时,无法在文本框中输入任何文本.这与正在使用Windows窗体事件循环有关吗?
In the F# WPF code below, I am unable to enter any text in the text box when I 'show' the WPF window from the F# FSI. Is this something to do with Windows Forms Event loop being used?
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中正常工作.
Based on the answer below by John Palmer, I have updated the code above with the correct version. The code below now works correctly in 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
推荐答案
You need to call Application.Run
- see here. This will start the event loop for you automatically.
这篇关于无法在F#FSI的WPF文本框中输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文