F # ( ), Silverlight . , :
, , XAML ( F # Silverlight, member let).
( ) Silverlight - Silverlight F # # Silverlight. . ( ) :
open System.Windows.Controls
let (?) (this : Control) (prop : string) : 'T = // '
this.FindName(prop) :?> 'T // '
type MyControl() as this =
inherit UserControl()
do
let path = "/MyProject;component/MyControl.xaml"
let uri = new System.Uri(path, UriKind.Relative)
Application.LoadComponent(this, uri)
let btn : Button = this?TestButton
btn.Add(fun _ -> btn.Text <- "Clicked!")