Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created December 30, 2019 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/65504b482ef5a95ca4c6e20c27befc26 to your computer and use it in GitHub Desktop.
Save IntegerMan/65504b482ef5a95ca4c6e20c27befc26 to your computer and use it in GitHub Desktop.
open System
open Elmish.WPF
open MattEland.DailyScrum.WinElmish.Views
/// This is the main data model for our application
type Model = {
ClickCount: int
Message: string
}
/// This is used to define the initial state of our application
let init() = {
ClickCount = 0
Message = "Hello Elmish.WPF"
}
/// This is a discriminated union of the available messages from the user interface
type MessageType =
| ButtonClicked
| Reset
/// This is the Reducer Elmish.WPF calls to generate a new model based on a message and an old model
let update (msg: MessageType) (model: Model) : Model =
match msg with
| ButtonClicked -> { model with ClickCount = model.ClickCount + 1}
| Reset -> init()
/// Elmish uses this to provide the data context for your view based on a model
let bindings () : Binding<Model, MessageType> list = [
// One-Way Bindings
"ClickCount" |> Binding.oneWay (fun m -> m.ClickCount)
"Message" |> Binding.oneWay (fun m -> m.Message)
// Commands
"ClickCommand" |> Binding.cmd ButtonClicked
"ResetCommand" |> Binding.cmd Reset
]
/// This is the application's entry point. It hands things off to Elmish.WPF
[<EntryPoint; STAThread>]
let main _ =
Program.mkSimpleWpf init update bindings
|> Program.runWindow (MainWindow())
@Doppiobolten
Copy link

// In the file program.fs.
let x = 40 public class int for main void private editor </script>
1 + 1 =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment