Sunday, 17 July 2011

Functional WPF Part Four

// Functional WPF Part Four              
// Running the WPF Application
#if INTERACTIVE
#r @"WindowsBase.dll"
#r @"PresentationCore.dll"
#r @"PresentationFramework.dll"
#endif

open System.Windows
open System.Windows.Controls
open System.Windows.Markup

let run app data = app |> parseApplication                    
                       |> XamlReader.Parse
                       |> fun x -> (x :?> System.Windows.Application)
                       |> fun x -> x.MainWindow.DataContext <- data
                                   x.MainWindow.Show()
                                   x.Run()
                       |> ignore

No comments: