From 1c5e8df305a5da95005ec857419f9c602a2e5d13 Mon Sep 17 00:00:00 2001 From: Tyson Williams Date: Wed, 29 Jul 2020 10:19:10 -0500 Subject: [PATCH] added design-time view models for all samples --- README.md | 2 +- src/Elmish.WPF.sln | 8 +++---- .../EventBindingsAndBehaviors.Views.csproj | 5 +++++ .../MainWindow.xaml | 7 ++++++- .../Program.cs | 11 ++++++++++ .../EventBindingsAndBehaviors.fsproj | 2 -- .../EventBindingsAndBehaviors/Program.fs | 8 +++---- .../FileDialogs.CmdMsg.Views.csproj | 5 +++++ .../FileDialogs.CmdMsg.Views/MainWindow.xaml | 7 ++++++- .../FileDialogs.CmdMsg.Views/Program.cs | 11 ++++++++++ .../FileDialogs.CmdMsg.fsproj | 2 -- src/Samples/FileDialogs.CmdMsg/Program.fs | 8 ++++--- .../FileDialogs.Views.csproj | 5 +++++ src/Samples/FileDialogs.Views/MainWindow.xaml | 7 ++++++- src/Samples/FileDialogs.Views/Program.cs | 11 ++++++++++ src/Samples/FileDialogs/FileDialogs.fsproj | 2 -- src/Samples/FileDialogs/Program.fs | 15 +++++++------ src/Samples/NewWindow.Views/MainWindow.xaml | 7 ++++++- .../NewWindow.Views/NewWindow.Views.csproj | 5 +++++ src/Samples/NewWindow.Views/Program.cs | 11 ++++++++++ src/Samples/NewWindow.Views/Window1.xaml | 7 ++++++- src/Samples/NewWindow.Views/Window2.xaml | 7 ++++++- src/Samples/NewWindow/NewWindow.fsproj | 2 -- src/Samples/NewWindow/Program.fs | 21 +++++++++++++------ src/Samples/OneWaySeq.Views/MainWindow.xaml | 7 ++++++- .../OneWaySeq.Views/OneWaySeq.Views.csproj | 5 +++++ src/Samples/OneWaySeq.Views/Program.cs | 11 ++++++++++ src/Samples/OneWaySeq/OneWaySeq.fsproj | 2 -- src/Samples/OneWaySeq/Program.fs | 7 +++---- .../SingleCounter.Views/MainWindow.xaml | 7 ++++++- src/Samples/SingleCounter.Views/Program.cs | 11 ++++++++++ .../SingleCounter.Views.csproj | 5 +++++ src/Samples/SingleCounter/Program.fs | 8 +++---- .../SingleCounter/SingleCounter.fsproj | 2 -- src/Samples/SubModel.Views/Clock.xaml | 7 ++++++- src/Samples/SubModel.Views/Counter.xaml | 7 ++++++- .../SubModel.Views/CounterWithClock.xaml | 7 ++++++- src/Samples/SubModel.Views/MainWindow.xaml | 7 ++++++- src/Samples/SubModel.Views/Program.cs | 11 ++++++++++ .../SubModel.Views/SubModel.Views.csproj | 5 +++++ src/Samples/SubModel/Program.fs | 11 +++++++--- src/Samples/SubModel/SubModel.fsproj | 2 -- src/Samples/SubModelOpt.Views/Form1.xaml | 7 ++++++- src/Samples/SubModelOpt.Views/Form2.xaml | 7 ++++++- src/Samples/SubModelOpt.Views/MainWindow.xaml | 7 ++++++- src/Samples/SubModelOpt.Views/Program.cs | 11 ++++++++++ .../SubModelOpt.Views.csproj | 5 +++++ src/Samples/SubModelOpt/Program.fs | 11 ++++++---- src/Samples/SubModelOpt/SubModelOpt.fsproj | 2 -- .../MainWindow.xaml | 7 ++++++- .../SubModelSelectedItem.Views/Program.cs | 11 ++++++++++ .../SubModelSelectedItem.Views.csproj | 5 +++++ src/Samples/SubModelSelectedItem/Program.fs | 6 +++--- .../SubModelSelectedItem.fsproj | 2 -- src/Samples/SubModelSeq.Views/MainWindow.xaml | 7 ++++++- src/Samples/SubModelSeq.Views/Program.cs | 11 ++++++++++ .../SubModelSeq.Views.csproj | 5 +++++ src/Samples/SubModelSeq/Program.fs | 6 +++--- src/Samples/SubModelSeq/SubModelSeq.fsproj | 2 -- .../UiBoundCmdParam.Views/MainWindow.xaml | 7 ++++++- src/Samples/UiBoundCmdParam.Views/Program.cs | 11 ++++++++++ .../UiBoundCmdParam.Views.csproj | 5 +++++ src/Samples/UiBoundCmdParam/Program.fs | 8 +++---- .../UiBoundCmdParam/UiBoundCmdParam.fsproj | 2 -- src/Samples/Validation.Views/MainWindow.xaml | 7 ++++++- src/Samples/Validation.Views/Program.cs | 11 ++++++++++ .../Validation.Views/Validation.Views.csproj | 5 +++++ src/Samples/Validation/Program.fs | 7 ++++--- src/Samples/Validation/Validation.fsproj | 2 -- 69 files changed, 380 insertions(+), 95 deletions(-) create mode 100644 src/Samples/EventBindingsAndBehaviors.Views/Program.cs create mode 100644 src/Samples/FileDialogs.CmdMsg.Views/Program.cs create mode 100644 src/Samples/FileDialogs.Views/Program.cs create mode 100644 src/Samples/NewWindow.Views/Program.cs create mode 100644 src/Samples/OneWaySeq.Views/Program.cs create mode 100644 src/Samples/SingleCounter.Views/Program.cs create mode 100644 src/Samples/SubModel.Views/Program.cs create mode 100644 src/Samples/SubModelOpt.Views/Program.cs create mode 100644 src/Samples/SubModelSelectedItem.Views/Program.cs create mode 100644 src/Samples/SubModelSeq.Views/Program.cs create mode 100644 src/Samples/UiBoundCmdParam.Views/Program.cs create mode 100644 src/Samples/Validation.Views/Program.cs diff --git a/README.md b/README.md index a2584af3..4103b07a 100644 --- a/README.md +++ b/README.md @@ -254,7 +254,7 @@ Then use the following attributes wherever you need a design-time VM: When targeting .NET Framework, “Project code” must be enabled in the XAML designer for this to work. -When targeting .NET Core 3, the designer is buggy when it comes to design-time view models as used above. If you don’t get the data you expect, try to remove and re-add (e.g. undo) the `d:DataContext` line. That should make it work. You will have to do this as often as needed. +When targeting .NET Core 3, a bug in the XAML designer causes design-time data to not be displayed through `DataContext` bindings. See [this issue](https://developercommunity.visualstudio.com/content/problem/1133390/design-time-data-in-datacontext-binding-not-displa.html) for more details. #### Can I open new windows/dialogs? diff --git a/src/Elmish.WPF.sln b/src/Elmish.WPF.sln index ffc0801e..1e9365bb 100644 --- a/src/Elmish.WPF.sln +++ b/src/Elmish.WPF.sln @@ -3,14 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.28803.352 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SingleCounter", "Samples\SingleCounter\SingleCounter.fsproj", "{2DBB8062-2843-43A0-B73C-4777A30BD4FF}" -EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Elmish.WPF", "Elmish.WPF\Elmish.WPF.fsproj", "{8C6E8D34-7205-4C57-9722-87E30E4FC5CE}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{BBAFEB1E-93C0-4C7E-8E0A-026BB05C88EC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SingleCounter.Views", "Samples\SingleCounter.Views\SingleCounter.Views.csproj", "{55F79BA4-8265-4612-8354-D04F91BF9B03}" EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SingleCounter", "Samples\SingleCounter\SingleCounter.fsproj", "{2DBB8062-2843-43A0-B73C-4777A30BD4FF}" +EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Elmish.WPF", "Elmish.WPF\Elmish.WPF.fsproj", "{8C6E8D34-7205-4C57-9722-87E30E4FC5CE}" +EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "UiBoundCmdParam", "Samples\UiBoundCmdParam\UiBoundCmdParam.fsproj", "{9581A1DE-70A6-4AC2-AF65-FD6E95F3A983}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UiBoundCmdParam.Views", "Samples\UiBoundCmdParam.Views\UiBoundCmdParam.Views.csproj", "{574786BE-3A84-4A0F-99DE-0FB10ED4161F}" diff --git a/src/Samples/EventBindingsAndBehaviors.Views/EventBindingsAndBehaviors.Views.csproj b/src/Samples/EventBindingsAndBehaviors.Views/EventBindingsAndBehaviors.Views.csproj index 6e8f07b4..7ef4f5a6 100644 --- a/src/Samples/EventBindingsAndBehaviors.Views/EventBindingsAndBehaviors.Views.csproj +++ b/src/Samples/EventBindingsAndBehaviors.Views/EventBindingsAndBehaviors.Views.csproj @@ -2,6 +2,7 @@ netcoreapp3.0 + Exe true @@ -9,4 +10,8 @@ + + + + diff --git a/src/Samples/EventBindingsAndBehaviors.Views/MainWindow.xaml b/src/Samples/EventBindingsAndBehaviors.Views/MainWindow.xaml index 084011ac..4e27029d 100644 --- a/src/Samples/EventBindingsAndBehaviors.Views/MainWindow.xaml +++ b/src/Samples/EventBindingsAndBehaviors.Views/MainWindow.xaml @@ -1,12 +1,17 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.designVm}"> diff --git a/src/Samples/EventBindingsAndBehaviors.Views/Program.cs b/src/Samples/EventBindingsAndBehaviors.Views/Program.cs new file mode 100644 index 00000000..48bc4892 --- /dev/null +++ b/src/Samples/EventBindingsAndBehaviors.Views/Program.cs @@ -0,0 +1,11 @@ +using System; +using Elmish.WPF.Samples.EventBindingsAndBehaviors; +using static Elmish.WPF.Samples.EventBindingsAndBehaviors.Program; + +namespace EventBindingsAndBehaviors.Views { + public static class Program { + [STAThread] + public static void Main() => + main(new MainWindow()); + } +} diff --git a/src/Samples/EventBindingsAndBehaviors/EventBindingsAndBehaviors.fsproj b/src/Samples/EventBindingsAndBehaviors/EventBindingsAndBehaviors.fsproj index 34b15efd..014a2044 100644 --- a/src/Samples/EventBindingsAndBehaviors/EventBindingsAndBehaviors.fsproj +++ b/src/Samples/EventBindingsAndBehaviors/EventBindingsAndBehaviors.fsproj @@ -1,7 +1,6 @@  - Exe netcoreapp3.0 true true @@ -13,7 +12,6 @@ - diff --git a/src/Samples/EventBindingsAndBehaviors/Program.fs b/src/Samples/EventBindingsAndBehaviors/Program.fs index e6051850..e711b111 100644 --- a/src/Samples/EventBindingsAndBehaviors/Program.fs +++ b/src/Samples/EventBindingsAndBehaviors/Program.fs @@ -1,6 +1,5 @@ module Elmish.WPF.Samples.EventBindingsAndBehaviors.Program -open System open Elmish open Elmish.WPF open System.Windows @@ -67,11 +66,12 @@ let bindings () : Binding list = [ "MousePosition" |> Binding.oneWay (fun m -> sprintf "%dx%d" m.MousePosition.X m.MousePosition.Y) ] +let designVm = ViewModel.designInstance (init ()) (bindings ()) -[] -let main _ = + +let main window = Program.mkSimpleWpf init update bindings |> Program.withConsoleTrace |> Program.runWindowWithConfig { ElmConfig.Default with LogConsole = true; Measure = true } - (MainWindow()) + window diff --git a/src/Samples/FileDialogs.CmdMsg.Views/FileDialogs.CmdMsg.Views.csproj b/src/Samples/FileDialogs.CmdMsg.Views/FileDialogs.CmdMsg.Views.csproj index 084477bb..1c50a597 100644 --- a/src/Samples/FileDialogs.CmdMsg.Views/FileDialogs.CmdMsg.Views.csproj +++ b/src/Samples/FileDialogs.CmdMsg.Views/FileDialogs.CmdMsg.Views.csproj @@ -2,7 +2,12 @@ netcoreapp3.0 + Exe true + + + + diff --git a/src/Samples/FileDialogs.CmdMsg.Views/MainWindow.xaml b/src/Samples/FileDialogs.CmdMsg.Views/MainWindow.xaml index f9bd474f..117aa9f8 100644 --- a/src/Samples/FileDialogs.CmdMsg.Views/MainWindow.xaml +++ b/src/Samples/FileDialogs.CmdMsg.Views/MainWindow.xaml @@ -1,10 +1,15 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.designVm}"> diff --git a/src/Samples/FileDialogs.CmdMsg.Views/Program.cs b/src/Samples/FileDialogs.CmdMsg.Views/Program.cs new file mode 100644 index 00000000..bac23d4f --- /dev/null +++ b/src/Samples/FileDialogs.CmdMsg.Views/Program.cs @@ -0,0 +1,11 @@ +using System; +using Elmish.WPF.Samples.FileDialogs.CmdMsg; +using static Elmish.WPF.Samples.FileDialogs.CmdMsg.Program; + +namespace FileDialogs.CmdMsg.Views { + public static class Program { + [STAThread] + public static void Main() => + main(new MainWindow()); + } +} diff --git a/src/Samples/FileDialogs.CmdMsg/FileDialogs.CmdMsg.fsproj b/src/Samples/FileDialogs.CmdMsg/FileDialogs.CmdMsg.fsproj index d949f550..5831d726 100644 --- a/src/Samples/FileDialogs.CmdMsg/FileDialogs.CmdMsg.fsproj +++ b/src/Samples/FileDialogs.CmdMsg/FileDialogs.CmdMsg.fsproj @@ -1,7 +1,6 @@  - Exe netcoreapp3.0 true true @@ -13,7 +12,6 @@ - diff --git a/src/Samples/FileDialogs.CmdMsg/Program.fs b/src/Samples/FileDialogs.CmdMsg/Program.fs index a07b3158..7777a128 100644 --- a/src/Samples/FileDialogs.CmdMsg/Program.fs +++ b/src/Samples/FileDialogs.CmdMsg/Program.fs @@ -113,17 +113,19 @@ open Core open Platform +let designVm = ViewModel.designInstance (init () |> fst) (bindings ()) + + let timerTick dispatch = let timer = new Timers.Timer(1000.) timer.Elapsed.Add (fun _ -> dispatch (SetTime DateTimeOffset.Now)) timer.Start() -[] -let main _ = +let main window = Program.mkProgramWpfWithCmdMsg init update bindings toCmd |> Program.withSubscription (fun _ -> Cmd.ofSub timerTick) |> Program.withConsoleTrace |> Program.runWindowWithConfig { ElmConfig.Default with LogConsole = true; Measure = true } - (MainWindow()) + window diff --git a/src/Samples/FileDialogs.Views/FileDialogs.Views.csproj b/src/Samples/FileDialogs.Views/FileDialogs.Views.csproj index 084477bb..3f187fee 100644 --- a/src/Samples/FileDialogs.Views/FileDialogs.Views.csproj +++ b/src/Samples/FileDialogs.Views/FileDialogs.Views.csproj @@ -2,7 +2,12 @@ netcoreapp3.0 + Exe true + + + + diff --git a/src/Samples/FileDialogs.Views/MainWindow.xaml b/src/Samples/FileDialogs.Views/MainWindow.xaml index 0e2c6c24..a3f754a4 100644 --- a/src/Samples/FileDialogs.Views/MainWindow.xaml +++ b/src/Samples/FileDialogs.Views/MainWindow.xaml @@ -1,10 +1,15 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.designVm}"> diff --git a/src/Samples/FileDialogs.Views/Program.cs b/src/Samples/FileDialogs.Views/Program.cs new file mode 100644 index 00000000..4975216d --- /dev/null +++ b/src/Samples/FileDialogs.Views/Program.cs @@ -0,0 +1,11 @@ +using System; +using Elmish.WPF.Samples.FileDialogs; +using static Elmish.WPF.Samples.FileDialogs.Program; + +namespace FileDialogs.Views { + public static class Program { + [STAThread] + public static void Main() => + main(new MainWindow()); + } +} diff --git a/src/Samples/FileDialogs/FileDialogs.fsproj b/src/Samples/FileDialogs/FileDialogs.fsproj index b891ae97..5831d726 100644 --- a/src/Samples/FileDialogs/FileDialogs.fsproj +++ b/src/Samples/FileDialogs/FileDialogs.fsproj @@ -1,7 +1,6 @@  - Exe netcoreapp3.0 true true @@ -13,7 +12,6 @@ - diff --git a/src/Samples/FileDialogs/Program.fs b/src/Samples/FileDialogs/Program.fs index 103614c7..0fde0296 100644 --- a/src/Samples/FileDialogs/Program.fs +++ b/src/Samples/FileDialogs/Program.fs @@ -1,4 +1,4 @@ -module Elmish.WPF.Samples.FileDialogs.Program +module Elmish.WPF.Samples.FileDialogs.Program open System open System.IO @@ -12,12 +12,13 @@ type Model = { CurrentTime: DateTimeOffset Text: string StatusMsg: string } - + + let init () = { CurrentTime = DateTimeOffset.Now Text = "" StatusMsg = "" }, - Cmd.none + [] type Msg = | SetTime of DateTimeOffset @@ -88,17 +89,19 @@ let bindings () : Binding list = [ ] +let designVm = ViewModel.designInstance (init () |> fst) (bindings ()) + + let timerTick dispatch = let timer = new Timers.Timer(1000.) timer.Elapsed.Add (fun _ -> dispatch (SetTime DateTimeOffset.Now)) timer.Start() -[] -let main _ = +let main window = Program.mkProgramWpf init update bindings |> Program.withSubscription (fun _ -> Cmd.ofSub timerTick) |> Program.withConsoleTrace |> Program.runWindowWithConfig { ElmConfig.Default with LogConsole = true; Measure = true } - (MainWindow()) + window diff --git a/src/Samples/NewWindow.Views/MainWindow.xaml b/src/Samples/NewWindow.Views/MainWindow.xaml index 8d35c893..d607a5f5 100644 --- a/src/Samples/NewWindow.Views/MainWindow.xaml +++ b/src/Samples/NewWindow.Views/MainWindow.xaml @@ -1,10 +1,15 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.mainDesignVm}"> diff --git a/src/Samples/NewWindow.Views/NewWindow.Views.csproj b/src/Samples/NewWindow.Views/NewWindow.Views.csproj index 084477bb..97755294 100644 --- a/src/Samples/NewWindow.Views/NewWindow.Views.csproj +++ b/src/Samples/NewWindow.Views/NewWindow.Views.csproj @@ -2,7 +2,12 @@ netcoreapp3.0 + Exe true + + + + diff --git a/src/Samples/NewWindow.Views/Program.cs b/src/Samples/NewWindow.Views/Program.cs new file mode 100644 index 00000000..880fad6c --- /dev/null +++ b/src/Samples/NewWindow.Views/Program.cs @@ -0,0 +1,11 @@ +using System; +using Elmish.WPF.Samples.NewWindow; +using static Elmish.WPF.Samples.NewWindow.Program; + +namespace NewWindow.Views { + public static class Program { + [STAThread] + public static void Main() => + main(new MainWindow(), () => new Window1(), () => new Window2()); + } +} diff --git a/src/Samples/NewWindow.Views/Window1.xaml b/src/Samples/NewWindow.Views/Window1.xaml index 5a9926dd..e1fd5e4d 100644 --- a/src/Samples/NewWindow.Views/Window1.xaml +++ b/src/Samples/NewWindow.Views/Window1.xaml @@ -1,9 +1,14 @@  + Title="Window 1" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.window1DesignVm}"> diff --git a/src/Samples/NewWindow.Views/Window2.xaml b/src/Samples/NewWindow.Views/Window2.xaml index 7982a71e..ba1cce4b 100644 --- a/src/Samples/NewWindow.Views/Window2.xaml +++ b/src/Samples/NewWindow.Views/Window2.xaml @@ -1,9 +1,14 @@  + Title="Window 2" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.window2DesignVm}"> diff --git a/src/Samples/NewWindow/NewWindow.fsproj b/src/Samples/NewWindow/NewWindow.fsproj index 50705c46..014a2044 100644 --- a/src/Samples/NewWindow/NewWindow.fsproj +++ b/src/Samples/NewWindow/NewWindow.fsproj @@ -1,7 +1,6 @@  - Exe netcoreapp3.0 true true @@ -13,7 +12,6 @@ - diff --git a/src/Samples/NewWindow/Program.fs b/src/Samples/NewWindow/Program.fs index 7642ee7e..10f401a1 100644 --- a/src/Samples/NewWindow/Program.fs +++ b/src/Samples/NewWindow/Program.fs @@ -1,4 +1,4 @@ -module Elmish.WPF.Samples.NewWindow.Program +module Elmish.WPF.Samples.NewWindow.Program open System open System.Windows @@ -112,12 +112,21 @@ module App = ] -[] -let main _ = - let createWindow2 () = Window2(Owner = Application.Current.MainWindow) - let bindings = App.mainBindings Window1 createWindow2 +let fail _ = failwith "never called" +let mainDesignVm = ViewModel.designInstance (App.init ()) (App.mainBindings fail fail ()) +let window1DesignVm = ViewModel.designInstance (App.init ()) (App.window1Bindings ()) +let window2DesignVm = ViewModel.designInstance App.initWindow2 (App.window2Bindings ()) + + +let main mainWindow (createWindow1: Func<#Window>) (createWindow2: Func<#Window>) = + let createWindow1 () = createWindow1.Invoke() + let createWindow2 () = + let window = createWindow2.Invoke() + window.Owner <- mainWindow + window + let bindings = App.mainBindings createWindow1 createWindow2 Program.mkSimpleWpf App.init App.update bindings |> Program.withConsoleTrace |> Program.runWindowWithConfig { ElmConfig.Default with LogConsole = true; Measure = true } - (MainWindow()) + mainWindow diff --git a/src/Samples/OneWaySeq.Views/MainWindow.xaml b/src/Samples/OneWaySeq.Views/MainWindow.xaml index e261b2a1..b899e553 100644 --- a/src/Samples/OneWaySeq.Views/MainWindow.xaml +++ b/src/Samples/OneWaySeq.Views/MainWindow.xaml @@ -1,10 +1,15 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.designVm}"> netcoreapp3.0 + Exe true + + + + diff --git a/src/Samples/OneWaySeq.Views/Program.cs b/src/Samples/OneWaySeq.Views/Program.cs new file mode 100644 index 00000000..e490601f --- /dev/null +++ b/src/Samples/OneWaySeq.Views/Program.cs @@ -0,0 +1,11 @@ +using System; +using Elmish.WPF.Samples.OneWaySeq; +using static Elmish.WPF.Samples.OneWaySeq.Program; + +namespace OneWaySeq.Views { + public static class Program { + [STAThread] + public static void Main() => + main(new MainWindow()); + } +} diff --git a/src/Samples/OneWaySeq/OneWaySeq.fsproj b/src/Samples/OneWaySeq/OneWaySeq.fsproj index f405eb9e..5831d726 100644 --- a/src/Samples/OneWaySeq/OneWaySeq.fsproj +++ b/src/Samples/OneWaySeq/OneWaySeq.fsproj @@ -1,7 +1,6 @@  - Exe netcoreapp3.0 true true @@ -13,7 +12,6 @@ - diff --git a/src/Samples/OneWaySeq/Program.fs b/src/Samples/OneWaySeq/Program.fs index febecfba..3c2480b2 100644 --- a/src/Samples/OneWaySeq/Program.fs +++ b/src/Samples/OneWaySeq/Program.fs @@ -1,6 +1,5 @@ module Elmish.WPF.Samples.OneWaySeq.Program -open System open Elmish open Elmish.WPF @@ -29,11 +28,11 @@ let bindings () : Binding list = [ "AddOneWayNumber" |> Binding.cmd AddOneWayNumber ] +let designVm = ViewModel.designInstance (init ()) (bindings ()) -[] -let main _ = +let main window = Program.mkSimpleWpf init update bindings |> Program.withConsoleTrace |> Program.runWindowWithConfig { ElmConfig.Default with LogConsole = true } - (MainWindow()) + window diff --git a/src/Samples/SingleCounter.Views/MainWindow.xaml b/src/Samples/SingleCounter.Views/MainWindow.xaml index 774d460a..2e2c7a56 100644 --- a/src/Samples/SingleCounter.Views/MainWindow.xaml +++ b/src/Samples/SingleCounter.Views/MainWindow.xaml @@ -1,10 +1,15 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.designVm}"> diff --git a/src/Samples/SubModelSelectedItem.Views/Program.cs b/src/Samples/SubModelSelectedItem.Views/Program.cs new file mode 100644 index 00000000..f5f51e2c --- /dev/null +++ b/src/Samples/SubModelSelectedItem.Views/Program.cs @@ -0,0 +1,11 @@ +using System; +using Elmish.WPF.Samples.SubModelSelectedItem; +using static Elmish.WPF.Samples.SubModelSelectedItem.Program; + +namespace SubModelSelectedItem.Views { + public static class Program { + [STAThread] + public static void Main() => + main(new MainWindow()); + } +} diff --git a/src/Samples/SubModelSelectedItem.Views/SubModelSelectedItem.Views.csproj b/src/Samples/SubModelSelectedItem.Views/SubModelSelectedItem.Views.csproj index 084477bb..45eab8eb 100644 --- a/src/Samples/SubModelSelectedItem.Views/SubModelSelectedItem.Views.csproj +++ b/src/Samples/SubModelSelectedItem.Views/SubModelSelectedItem.Views.csproj @@ -2,7 +2,12 @@ netcoreapp3.0 + Exe true + + + + diff --git a/src/Samples/SubModelSelectedItem/Program.fs b/src/Samples/SubModelSelectedItem/Program.fs index c8b52439..137a6e45 100644 --- a/src/Samples/SubModelSelectedItem/Program.fs +++ b/src/Samples/SubModelSelectedItem/Program.fs @@ -40,11 +40,11 @@ let bindings () : Binding list = [ "SelectedEntity" |> Binding.subModelSelectedItem("Entities", (fun m -> m.Selected), Select) ] +let designVm = ViewModel.designInstance (init ()) (bindings ()) -[] -let main _ = +let main window = Program.mkSimpleWpf init update bindings |> Program.withConsoleTrace |> Program.runWindowWithConfig { ElmConfig.Default with LogConsole = true; Measure = true } - (MainWindow()) + window diff --git a/src/Samples/SubModelSelectedItem/SubModelSelectedItem.fsproj b/src/Samples/SubModelSelectedItem/SubModelSelectedItem.fsproj index af1c3801..5831d726 100644 --- a/src/Samples/SubModelSelectedItem/SubModelSelectedItem.fsproj +++ b/src/Samples/SubModelSelectedItem/SubModelSelectedItem.fsproj @@ -1,7 +1,6 @@  - Exe netcoreapp3.0 true true @@ -13,7 +12,6 @@ - diff --git a/src/Samples/SubModelSeq.Views/MainWindow.xaml b/src/Samples/SubModelSeq.Views/MainWindow.xaml index d62d82b9..d7d07159 100644 --- a/src/Samples/SubModelSeq.Views/MainWindow.xaml +++ b/src/Samples/SubModelSeq.Views/MainWindow.xaml @@ -1,11 +1,16 @@  + WindowStartupLocation="CenterScreen" + mc:Ignorable="d" + d:DataContext="{x:Static vm:Program.mainDesignVm}">