Skip to content

Commit 3d76eaa

Browse files
committed
Add typed navigation sample
Add a sample how to create a simple module based navigation using typed view models. Fix solution file structure.
1 parent 5a480df commit 3d76eaa

File tree

14 files changed

+410
-28
lines changed

14 files changed

+410
-28
lines changed

Elmish.WPF.sln

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubModelStatic", "src\Sampl
8787
EndProject
8888
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SubModelStatic.Core", "src\Samples\Typed\SubModelStatic.Core\SubModelStatic.Core.fsproj", "{A7BA896C-1D7E-4336-BE50-032BF8E62D81}"
8989
EndProject
90-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Typed Samples", "Typed Samples", "{D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}"
91-
EndProject
9290
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SingleCounter.Core", "src\Samples\Typed\SingleCounter.Core\SingleCounter.Core.fsproj", "{F964D761-6542-4A3C-8ADC-41F5B8F77529}"
9391
EndProject
9492
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SingleCounter", "src\Samples\Typed\SingleCounter\SingleCounter.csproj", "{148B26DF-05B6-44D6-890D-8AFBFAD9F7D9}"
@@ -133,14 +131,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Threading.Core", "src\Sampl
133131
EndProject
134132
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Threading", "src\Samples\Typed\Threading\Threading.csproj", "{E6476EE0-71CA-4E5D-BE05-E57825E8AECB}"
135133
EndProject
136-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SamplesTyped", "SamplesTyped", "{4CA4C854-E741-1F89-40C8-44936FD249BC}"
137-
EndProject
138134
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Multiselect.Core", "src\Samples\Typed\Multiselect.Core\Multiselect.Core.fsproj", "{984CD20C-0F0A-4458-A3ED-6CC9BE2A1DC8}"
139135
EndProject
140136
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Multiselect", "src\Samples\Typed\Multiselect\Multiselect.csproj", "{20D9470B-F39E-4E67-A00D-9714D6E857DE}"
141137
EndProject
142-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Typed", "Typed", "{66D998A7-9C00-98D2-A5B4-91D444794DB6}"
143-
EndProject
144138
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SubModelSelectedItem.Core", "src\Samples\Typed\SubModelSelectedItem.Core\SubModelSelectedItem.Core.fsproj", "{5D54DD79-59AA-4C85-8ECA-CAC59D86F251}"
145139
EndProject
146140
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubModelSelectedItem", "src\Samples\Typed\SubModelSelectedItem\SubModelSelectedItem.csproj", "{F10A1DEA-545F-4C9F-AFA1-A115726BD415}"
@@ -153,6 +147,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Capabilities.Core", "src\Sa
153147
EndProject
154148
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Capabilities", "src\Samples\Typed\Capabilities\Capabilities.csproj", "{8B54C3E2-5F8B-471B-83DF-26239DF1C5C8}"
155149
EndProject
150+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Navigation", "src\Samples\Typed\Navigation\Navigation.csproj", "{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}"
151+
EndProject
152+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Navigation.Core", "src\Samples\Typed\Navigation.Core\Navigation.Core.fsproj", "{46397A4D-287C-410E-BDE9-1F09D7E64EF0}"
153+
EndProject
156154
Global
157155
GlobalSection(SolutionConfigurationPlatforms) = preSolution
158156
Debug|Any CPU = Debug|Any CPU
@@ -967,6 +965,30 @@ Global
967965
{8B54C3E2-5F8B-471B-83DF-26239DF1C5C8}.Release|x64.Build.0 = Release|Any CPU
968966
{8B54C3E2-5F8B-471B-83DF-26239DF1C5C8}.Release|x86.ActiveCfg = Release|Any CPU
969967
{8B54C3E2-5F8B-471B-83DF-26239DF1C5C8}.Release|x86.Build.0 = Release|Any CPU
968+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
969+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
970+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Debug|x64.ActiveCfg = Debug|Any CPU
971+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Debug|x64.Build.0 = Debug|Any CPU
972+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Debug|x86.ActiveCfg = Debug|Any CPU
973+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Debug|x86.Build.0 = Debug|Any CPU
974+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
975+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Release|Any CPU.Build.0 = Release|Any CPU
976+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Release|x64.ActiveCfg = Release|Any CPU
977+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Release|x64.Build.0 = Release|Any CPU
978+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Release|x86.ActiveCfg = Release|Any CPU
979+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0}.Release|x86.Build.0 = Release|Any CPU
980+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
981+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
982+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Debug|x64.ActiveCfg = Debug|Any CPU
983+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Debug|x64.Build.0 = Debug|Any CPU
984+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Debug|x86.ActiveCfg = Debug|Any CPU
985+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Debug|x86.Build.0 = Debug|Any CPU
986+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
987+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Release|Any CPU.Build.0 = Release|Any CPU
988+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Release|x64.ActiveCfg = Release|Any CPU
989+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Release|x64.Build.0 = Release|Any CPU
990+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Release|x86.ActiveCfg = Release|Any CPU
991+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0}.Release|x86.Build.0 = Release|Any CPU
970992
EndGlobalSection
971993
GlobalSection(SolutionProperties) = preSolution
972994
HideSolutionNode = FALSE
@@ -1012,20 +1034,6 @@ Global
10121034
{1740D47D-DA94-6415-017E-48203BA1C52C} = {D1B4CF99-7947-DD6C-81D0-5B5B3989814C}
10131035
{2A113076-21F0-4F11-A1CF-D0E4A1D14503} = {1740D47D-DA94-6415-017E-48203BA1C52C}
10141036
{A7BA896C-1D7E-4336-BE50-032BF8E62D81} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1015-
{F964D761-6542-4A3C-8ADC-41F5B8F77529} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1016-
{148B26DF-05B6-44D6-890D-8AFBFAD9F7D9} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1017-
{6455B74A-6CB8-4DC3-9329-3D9CBB56173A} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1018-
{84AF37C1-52A8-4F3F-8F2C-E7394E789523} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1019-
{75110CC0-5A94-4491-BA7E-234ACC39106D} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1020-
{8F1471D6-CEFA-4B4F-84C5-FB4B5CB035BD} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1021-
{A57D4155-3F27-4BDA-900E-1A39B022BE00} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1022-
{86E04393-86E7-4BBF-A9EF-9433B91E4988} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1023-
{B9C9B2A4-562B-45BB-BD91-CE5027F41C3F} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1024-
{435B3E59-C5B2-412A-86DC-795F1E52C223} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1025-
{6E4E4453-36C8-42FC-9B8A-C8FEBCC6A643} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1026-
{CAD2DE5B-A359-4E51-8138-A02FDCA8E2A6} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1027-
{A3D2D2D1-413E-4367-B1D5-0AEEB1551240} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
1028-
{03FA4F94-962D-4324-B71E-D36E638D13D7} = {D7ABC870-FF0D-D4D3-9CFF-039FA9E62307}
10291037
{197B01F2-1974-46A1-9C40-7303E405BFA7} = {1740D47D-DA94-6415-017E-48203BA1C52C}
10301038
{0C0BBD9A-1AC7-4B54-B725-03535AE033F1} = {1740D47D-DA94-6415-017E-48203BA1C52C}
10311039
{1093E8A9-77C3-43A0-ACA2-E0857EC19AED} = {1740D47D-DA94-6415-017E-48203BA1C52C}
@@ -1034,13 +1042,29 @@ Global
10341042
{BB30719A-3461-493E-972F-F6CEF534163E} = {1740D47D-DA94-6415-017E-48203BA1C52C}
10351043
{9ECB1F3B-3076-4C98-9ECA-6ACE8C8CAB2A} = {1740D47D-DA94-6415-017E-48203BA1C52C}
10361044
{E6476EE0-71CA-4E5D-BE05-E57825E8AECB} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1037-
{984CD20C-0F0A-4458-A3ED-6CC9BE2A1DC8} = {4CA4C854-E741-1F89-40C8-44936FD249BC}
1038-
{20D9470B-F39E-4E67-A00D-9714D6E857DE} = {4CA4C854-E741-1F89-40C8-44936FD249BC}
1039-
{5D54DD79-59AA-4C85-8ECA-CAC59D86F251} = {66D998A7-9C00-98D2-A5B4-91D444794DB6}
1040-
{F10A1DEA-545F-4C9F-AFA1-A115726BD415} = {66D998A7-9C00-98D2-A5B4-91D444794DB6}
1041-
{0330D3D5-5A97-4F6D-AE22-993256ABDFEE} = {66D998A7-9C00-98D2-A5B4-91D444794DB6}
1042-
{565FC442-5E49-42AD-AC33-14AD14E11961} = {66D998A7-9C00-98D2-A5B4-91D444794DB6}
1043-
{F6BB74C6-971A-44D7-BC10-3B37B74DE264} = {66D998A7-9C00-98D2-A5B4-91D444794DB6}
1044-
{8B54C3E2-5F8B-471B-83DF-26239DF1C5C8} = {66D998A7-9C00-98D2-A5B4-91D444794DB6}
1045+
{1C8C9F58-A63E-4ED6-A185-F26F672EEDE0} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1046+
{46397A4D-287C-410E-BDE9-1F09D7E64EF0} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1047+
{8B54C3E2-5F8B-471B-83DF-26239DF1C5C8} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1048+
{F6BB74C6-971A-44D7-BC10-3B37B74DE264} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1049+
{565FC442-5E49-42AD-AC33-14AD14E11961} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1050+
{0330D3D5-5A97-4F6D-AE22-993256ABDFEE} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1051+
{F10A1DEA-545F-4C9F-AFA1-A115726BD415} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1052+
{5D54DD79-59AA-4C85-8ECA-CAC59D86F251} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1053+
{CAD2DE5B-A359-4E51-8138-A02FDCA8E2A6} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1054+
{6E4E4453-36C8-42FC-9B8A-C8FEBCC6A643} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1055+
{148B26DF-05B6-44D6-890D-8AFBFAD9F7D9} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1056+
{F964D761-6542-4A3C-8ADC-41F5B8F77529} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1057+
{435B3E59-C5B2-412A-86DC-795F1E52C223} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1058+
{B9C9B2A4-562B-45BB-BD91-CE5027F41C3F} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1059+
{86E04393-86E7-4BBF-A9EF-9433B91E4988} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1060+
{A57D4155-3F27-4BDA-900E-1A39B022BE00} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1061+
{8F1471D6-CEFA-4B4F-84C5-FB4B5CB035BD} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1062+
{75110CC0-5A94-4491-BA7E-234ACC39106D} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1063+
{03FA4F94-962D-4324-B71E-D36E638D13D7} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1064+
{A3D2D2D1-413E-4367-B1D5-0AEEB1551240} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1065+
{84AF37C1-52A8-4F3F-8F2C-E7394E789523} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1066+
{6455B74A-6CB8-4DC3-9329-3D9CBB56173A} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1067+
{984CD20C-0F0A-4458-A3ED-6CC9BE2A1DC8} = {1740D47D-DA94-6415-017E-48203BA1C52C}
1068+
{20D9470B-F39E-4E67-A00D-9714D6E857DE} = {1740D47D-DA94-6415-017E-48203BA1C52C}
10451069
EndGlobalSection
10461070
EndGlobal

Elmish.WPF.slnx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
<Project Path="src/Samples/Typed/FileDialogsCmdMsg/FileDialogsCmdMsg.csproj" />
5858
<Project Path="src/Samples/Typed/Multiselect.Core/Multiselect.Core.fsproj" />
5959
<Project Path="src/Samples/Typed/Multiselect/Multiselect.csproj" />
60+
<Project Path="src/Samples/Typed/Navigation.Core/Navigation.Core.fsproj" />
61+
<Project Path="src/Samples/Typed/Navigation/Navigation.csproj" />
6062
<Project Path="src/Samples/Typed/NewWindow.Core/NewWindow.Core.fsproj" />
6163
<Project Path="src/Samples/Typed/NewWindow/NewWindow.csproj" />
6264
<Project Path="src/Samples/Typed/OneWaySeq.Core/OneWaySeq.Core.fsproj" />
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
namespace Navigation.Core
2+
3+
4+
open System
5+
open Elmish
6+
open Elmish.WPF
7+
open Serilog
8+
open Serilog.Extensions.Logging
9+
10+
11+
[<RequireQualifiedAccess>]
12+
module Dashboard =
13+
type Model = { Title: string }
14+
15+
module Model =
16+
let empty = { Title = "Dashboard" }
17+
18+
type Message = | Idle
19+
20+
let init () = Model.empty, Cmd.none
21+
22+
let update message model = model, Cmd.none
23+
24+
type DashboardViewModel(args) =
25+
inherit ViewModelBase<Dashboard.Model, Dashboard.Message>(args)
26+
27+
member _.Title = base.Get () (Binding.OneWayT.id >> Binding.mapModel _.Title)
28+
29+
[<RequireQualifiedAccess>]
30+
module Customer =
31+
type Model =
32+
{ Title: string
33+
CurrentTime: DateTime option }
34+
35+
module Model =
36+
let empty = { Title = "Kunden"; CurrentTime = None }
37+
38+
type Message = | GetTime
39+
40+
let init () = Model.empty, Cmd.none
41+
42+
let update message model =
43+
match message with
44+
| GetTime ->
45+
{ model with
46+
CurrentTime = Some(DateTime.Now) },
47+
Cmd.none
48+
49+
type CustomerViewModel(args) =
50+
inherit ViewModelBase<Customer.Model, Customer.Message>(args)
51+
52+
member _.Title = base.Get () (Binding.OneWayT.id >> Binding.mapModel _.Title)
53+
54+
member _.CurrentTime =
55+
base.Get () (Binding.OneWayT.opt >> Binding.mapModel _.CurrentTime)
56+
57+
member _.GetTime = base.Get () (Binding.CmdT.setAlways Customer.GetTime)
58+
59+
[<RequireQualifiedAccess>]
60+
module Main =
61+
type Uri =
62+
| Dashboard = 0
63+
| Customer = 1
64+
65+
type Page =
66+
| Dashboard of Dashboard.Model
67+
| Customer of Customer.Model
68+
69+
type Model = { Title: string; ActivePage: Page }
70+
71+
module Model =
72+
let empty =
73+
{ Title = "App Navigation"
74+
ActivePage = Dashboard(fst (Dashboard.init ())) }
75+
76+
type Message =
77+
| Navigate of obj
78+
| DashboardMessage of Dashboard.Message
79+
| CustomerMessage of Customer.Message
80+
81+
let init () = Model.empty, Cmd.none
82+
83+
let update message model =
84+
match message with
85+
| CustomerMessage msg ->
86+
match model.ActivePage with
87+
| Customer custModel ->
88+
let updatedCustModel, cmd = Customer.update msg custModel
89+
{ model with ActivePage = Customer updatedCustModel },
90+
Cmd.map CustomerMessage cmd
91+
| _ -> model, Cmd.none
92+
| DashboardMessage msg ->
93+
match model.ActivePage with
94+
| Dashboard dashModel ->
95+
let updatedDashModel, cmd = Dashboard.update msg dashModel
96+
{ model with ActivePage = Dashboard updatedDashModel },
97+
Cmd.map DashboardMessage cmd
98+
| _ -> model, Cmd.none
99+
| Navigate p ->
100+
match (p :?> Uri) with
101+
| Uri.Dashboard ->
102+
{ model with
103+
ActivePage = Dashboard(fst (Dashboard.init ())) },
104+
Cmd.none
105+
| Uri.Customer ->
106+
{ model with
107+
ActivePage = Customer(fst (Customer.init ())) },
108+
Cmd.none
109+
| _ -> System.ArgumentOutOfRangeException() |> raise
110+
111+
type MainViewModel(args) as this =
112+
inherit ViewModelBase<Main.Model, Main.Message>(args)
113+
114+
member this.Title = base.Get () (Binding.OneWayT.id >> Binding.mapModel _.Title)
115+
116+
member this.Dashboard =
117+
base.Get
118+
()
119+
(Binding.SubModelT.req DashboardViewModel
120+
>> Binding.mapModel (fun (m: Main.Model) ->
121+
match m.ActivePage with
122+
| Main.Dashboard mdl -> mdl
123+
| _ -> fst (Dashboard.init ()))
124+
>> Binding.mapMsg Main.DashboardMessage
125+
>> Binding.boxT)
126+
127+
member this.Customer =
128+
base.Get
129+
()
130+
(Binding.SubModelT.req CustomerViewModel
131+
>> Binding.mapModel (fun (m: Main.Model) ->
132+
match m.ActivePage with
133+
| Main.Customer mdl -> mdl
134+
| _ -> fst (Customer.init ()))
135+
>> Binding.mapMsg Main.CustomerMessage
136+
>> Binding.boxT)
137+
138+
// Map of page types to their ViewModel properties
139+
member this.GetViewModelForPage(page: Main.Page) =
140+
match page with
141+
| Main.Dashboard _ -> this.Dashboard
142+
| Main.Customer _ -> this.Customer
143+
144+
member this.Content =
145+
base.Get
146+
()
147+
(Binding.OneWayT.id
148+
>> Binding.mapModel (fun (m: Main.Model) -> this.GetViewModelForPage(m.ActivePage)))
149+
150+
member _.Navigate =
151+
base.Get () (Binding.CmdT.id true (fun param model -> true) >> Binding.mapMsg Main.Navigate)
152+
153+
[<RequireQualifiedAccess>]
154+
module Program =
155+
let run window =
156+
let logger =
157+
LoggerConfiguration()
158+
.MinimumLevel.Override("Elmish.WPF.Update", Events.LogEventLevel.Verbose)
159+
.MinimumLevel.Override("Elmish.WPF.Bindings", Events.LogEventLevel.Verbose)
160+
.MinimumLevel.Override("Elmish.WPF.Performance", Events.LogEventLevel.Verbose)
161+
.WriteTo.Console()
162+
.CreateLogger()
163+
164+
WpfProgram.mkProgramT Main.init Main.update MainViewModel
165+
|> WpfProgram.withLogger (new SerilogLoggerFactory(logger))
166+
|> WpfProgram.startElmishLoop window
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0-windows</TargetFramework>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
<UseWpf>true</UseWpf>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Compile Include="Library.fs" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Serilog" Version="2.11.0"/>
15+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0"/>
16+
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1"/>
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\..\Elmish.WPF\Elmish.WPF.fsproj" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Application x:Class="Navigation.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<Application.Resources>
6+
7+
</Application.Resources>
8+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Navigation.Core;
2+
3+
namespace Navigation;
4+
5+
public partial class App
6+
{
7+
public App()
8+
{
9+
Activated += StartElmish;
10+
}
11+
12+
private void StartElmish(object? sender, EventArgs e)
13+
{
14+
Activated -= StartElmish;
15+
Program.run(MainWindow);
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly:ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<UserControl x:Class="Navigation.CustomerView"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:vm="clr-namespace:Navigation.Core;assembly=Navigation.Core"
7+
mc:Ignorable="d"
8+
d:DataContext="{d:DesignInstance vm:CustomerViewModel}"
9+
d:DesignHeight="300" d:DesignWidth="300">
10+
<DockPanel LastChildFill="True">
11+
<TextBlock Text="{Binding Title}" DockPanel.Dock="Top" FontSize="16" Margin="10" />
12+
<StackPanel Orientation="Vertical" Margin="10">
13+
<Button Content="Get Current Time" Command="{Binding GetTime}" />
14+
<TextBlock Text="{Binding CurrentTime, StringFormat='yyyy-MM-dd HH:mm:ss.fffff zzzzz'}" />
15+
</StackPanel>
16+
</DockPanel>
17+
</UserControl>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Windows.Controls;
2+
3+
namespace Navigation;
4+
5+
public partial class CustomerView : UserControl
6+
{
7+
public CustomerView()
8+
{
9+
InitializeComponent();
10+
}
11+
}

0 commit comments

Comments
 (0)