1

通过引用默认的 WPF DLL,使用纯代码 WPF 可以很容易地做任何事情:

#r "Accessibility.dll"
#r "PresentationCore.dll"
#r "PresentationFramework.dll"
#r "System.Core.dll"
#r "System.Data.dll"
#r "System.dll"
#r "System.Drawing.dll"
#r "System.Numerics.dll"
#r "System.Xaml.dll"
#r "System.Xml.dll"
#r "UIAutomationProvider.dll"
#r "UIAutomationTypes.dll"
#r "WindowsBase.dll"

let window = System.Windows.Window()
let panel = System.Windows.Controls.StackPanel()
let button = System.Windows.Controls.Button()
panel.Children.Add button
button.Content <- "hi"

window.Content <- panel

window.Show()

...您可以在窗口仍打开时对其进行操作...

button.Click.Add (fun _ ->
    button.Content <-
        button.Content :?> string |> fun x -> (x + "!") :> obj)

...然后单击按钮以查看它的工作原理。这似乎是构建 UI 组件的一种非常强大的方法。

有没有办法用 Xamarin.Forms 做同样的事情?

4

0 回答 0