From a215d8de827c627c4e46a346027a81734eb17bc0 Mon Sep 17 00:00:00 2001 From: SuperBrain Date: Thu, 16 Jul 2020 17:55:02 +0200 Subject: [PATCH] - Changed ShellViewModel to use Conductor - Added MainView/ViewModel - Changed MainViewModel to use Conductor.StackNavigation - Changed ShellView to use ContentControl that displays MainViewModel --- DynamicMenu/Pages/MainView.xaml | 23 +++++++++++++++++++++++ DynamicMenu/Pages/MainView.xaml.cs | 26 ++++++++++++++++++++++++++ DynamicMenu/Pages/MainViewModel.cs | 9 +++++++++ DynamicMenu/Pages/ShellView.xaml | 8 ++------ DynamicMenu/Pages/ShellViewModel.cs | 12 ++++++++++-- 5 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 DynamicMenu/Pages/MainView.xaml create mode 100644 DynamicMenu/Pages/MainView.xaml.cs create mode 100644 DynamicMenu/Pages/MainViewModel.cs diff --git a/DynamicMenu/Pages/MainView.xaml b/DynamicMenu/Pages/MainView.xaml new file mode 100644 index 0000000..5999f6e --- /dev/null +++ b/DynamicMenu/Pages/MainView.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/DynamicMenu/Pages/MainView.xaml.cs b/DynamicMenu/Pages/MainView.xaml.cs new file mode 100644 index 0000000..dc717af --- /dev/null +++ b/DynamicMenu/Pages/MainView.xaml.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace DynamicMenu.Pages +{ + /// + /// Interaction logic for MainView.xaml + /// + public partial class MainView : UserControl + { + public MainView() + { + InitializeComponent(); + } + } +} diff --git a/DynamicMenu/Pages/MainViewModel.cs b/DynamicMenu/Pages/MainViewModel.cs new file mode 100644 index 0000000..624247f --- /dev/null +++ b/DynamicMenu/Pages/MainViewModel.cs @@ -0,0 +1,9 @@ +using System; +using Stylet; + +namespace DynamicMenu.Pages +{ + public class MainViewModel : Conductor.StackNavigation + { + } +} diff --git a/DynamicMenu/Pages/ShellView.xaml b/DynamicMenu/Pages/ShellView.xaml index 6e4faae..02ee90a 100644 --- a/DynamicMenu/Pages/ShellView.xaml +++ b/DynamicMenu/Pages/ShellView.xaml @@ -7,10 +7,6 @@ xmlns:local="clr-namespace:Company.WpfApplication1.Pages" mc:Ignorable="d" d:DataContext="{d:DesignInstance local:ShellViewModel}" - Title="Stylet Project" Height="450" Width="800"> - - - Hello Stylet! - - + Title="Stylet Dynamic Menu" Height="600" Width="1200"> + diff --git a/DynamicMenu/Pages/ShellViewModel.cs b/DynamicMenu/Pages/ShellViewModel.cs index ee58c0b..71b25b8 100644 --- a/DynamicMenu/Pages/ShellViewModel.cs +++ b/DynamicMenu/Pages/ShellViewModel.cs @@ -1,8 +1,16 @@ -using Stylet; +using DynamicMenu.Pages; +using Stylet; namespace Company.WpfApplication1.Pages { - public class ShellViewModel : Screen + public class ShellViewModel : Conductor { + public MainViewModel MainVM { get; set; } + + public ShellViewModel() + { + MainVM = new MainViewModel(); + this.ActivateItem(MainVM); + } } }