Sunday, 17 July 2011

Functional WPF Part One

// Functional WPF (An Experiment in F# DSL to Xaml)

open System
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns

// Type Definitions

type Color = Red | Green | Blue

type Orientation = Horizontal | Vertical

type Attribute = Width of int
               | Height of int

type DataTemplate = DataTemplate of FrameworkElement

and FrameworkElement
        = Label of string * Attribute list
        | Button of string
        | TextBox of Attribute list * Expr
        | StackPanel of FrameworkElement list * Attribute list * Orientation
        | Border of Color * FrameworkElement
        | ItemsControl of DataTemplate

type Window = Window of FrameworkElement * Attribute list

type Application = Application of Window

No comments: