-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControls.fs
37 lines (30 loc) · 917 Bytes
/
Controls.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace Minimal.Controls
open Elmish.WPF
module TestControl =
type Model =
{
Count: int
SomeParam: string
}
type Msg =
| Increment
| Decrement
let init someParam =
{
Count = 0
SomeParam = someParam
}
let update msg m =
match msg with
| Increment -> { m with Count = m.Count + 1 }
| Decrement -> { m with Count = m.Count - 1 }
let bindings() =
[
"SomeParam" |> Binding.oneWay(fun m -> m.SomeParam)
"Count" |> Binding.oneWay (fun m -> m.Count)
"Increment" |> Binding.cmd Increment
"Decrement" |> Binding.cmd Decrement
]
let initWithControl control someParam =
Program.mkSimpleWpf (fun () -> init someParam) update bindings
|> Program.startElmishLoop ElmConfig.Default control