diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs
index 918dbaa..d8e0ca4 100644
--- a/Apollon.WPF/App.xaml.cs
+++ b/Apollon.WPF/App.xaml.cs
@@ -15,17 +15,21 @@ namespace Apollon.WPF
///
public partial class App : Application
{
+ private readonly ModalNavigationStore _modalNavigationStore;
private readonly SelectedTournamentStore _selectedTournamentStore;
public App()
{
+ _modalNavigationStore = new ModalNavigationStore();
_selectedTournamentStore = new SelectedTournamentStore();
}
protected override void OnStartup(StartupEventArgs e)
{
+ OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore);
+
MainWindow = new MainWindow()
{
- DataContext = new OverviewViewModel(_selectedTournamentStore)
+ DataContext = new MainViewModel(_modalNavigationStore, overviewViewModel)
};
MainWindow.Show();
diff --git a/Apollon.WPF/MainWindow.xaml b/Apollon.WPF/MainWindow.xaml
index 9e1cf85..7491888 100644
--- a/Apollon.WPF/MainWindow.xaml
+++ b/Apollon.WPF/MainWindow.xaml
@@ -16,15 +16,14 @@
-
+
-
-
+ >
diff --git a/Apollon.WPF/Stores/ModalNavigationStore.cs b/Apollon.WPF/Stores/ModalNavigationStore.cs
new file mode 100644
index 0000000..908a6ab
--- /dev/null
+++ b/Apollon.WPF/Stores/ModalNavigationStore.cs
@@ -0,0 +1,31 @@
+using Apollon.WPF.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Apollon.WPF.Stores
+{
+ public class ModalNavigationStore
+ {
+ private ViewModelBase _currentViewModel
+ ;
+ public ViewModelBase CurrentViewModel
+ {
+ get
+ {
+ return _currentViewModel;
+ }
+ set
+ {
+ _currentViewModel = value;
+ CurrentViewModelChanged?.Invoke();
+ }
+ }
+
+ public bool IsOpen => CurrentViewModel != null;
+
+ public event Action CurrentViewModelChanged;
+ }
+}
diff --git a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs
index ec48dd6..9096088 100644
--- a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs
+++ b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs
@@ -3,10 +3,102 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
namespace Apollon.WPF.ViewModels
{
- internal class AddEditDetailsViewModel
+ public class AddEditDetailsViewModel : ViewModelBase
{
+ private string _organisation;
+ public string Organisation
+ {
+ get
+ {
+ return _organisation;
+ }
+ set
+ {
+ _organisation = value;
+ OnPropertyChanged(nameof(Organisation));
+ }
+ }
+
+ private string _tournamentname;
+ public string Tounamentname
+ {
+ get
+ {
+ return _tournamentname;
+ }
+ set
+ {
+ _tournamentname = value;
+ OnPropertyChanged(nameof(Tounamentname));
+ OnPropertyChanged(nameof(CanSubmit));
+ }
+ }
+
+ private string _category;
+ public string Category
+ {
+ get
+ {
+ return _category;
+ }
+ set
+ {
+ _category = value;
+ OnPropertyChanged(nameof(Category));
+ }
+ }
+
+ private string _startdate;
+ public string Startdate
+ {
+ get
+ {
+ return _startdate;
+ }
+ set
+ {
+ _startdate = value;
+ OnPropertyChanged(nameof(Startdate));
+ }
+ }
+
+ private string _enddate;
+ public string Enddate
+ {
+ get
+ {
+ return _enddate;
+ }
+ set
+ {
+ _enddate = value;
+ OnPropertyChanged(nameof(Enddate));
+ }
+ }
+
+ private string _location;
+ public string Location
+ {
+ get
+ {
+ return _location;
+ }
+ set
+ {
+ _location = value;
+ OnPropertyChanged(nameof(Location));
+ }
+ }
+
+ public bool CanSubmit => !string.IsNullOrEmpty(Tounamentname);
+ public ICommand SubmitCommand { get; }
+ public ICommand CancleCommand { get; }
}
+
+
+
}
diff --git a/Apollon.WPF/ViewModels/AddTournametViewModel.cs b/Apollon.WPF/ViewModels/AddTournametViewModel.cs
index aa58e8c..7d6c537 100644
--- a/Apollon.WPF/ViewModels/AddTournametViewModel.cs
+++ b/Apollon.WPF/ViewModels/AddTournametViewModel.cs
@@ -6,7 +6,14 @@ using System.Threading.Tasks;
namespace Apollon.WPF.ViewModels
{
- internal class AddTournametViewModel
+ public class AddTournametViewModel : ViewModelBase
{
+ public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
+
+ public AddTournametViewModel()
+ {
+ AddEditDetailsViewModel = new AddEditDetailsViewModel();
+ }
+
}
}
diff --git a/Apollon.WPF/ViewModels/MainViewModel.cs b/Apollon.WPF/ViewModels/MainViewModel.cs
new file mode 100644
index 0000000..c3d07bf
--- /dev/null
+++ b/Apollon.WPF/ViewModels/MainViewModel.cs
@@ -0,0 +1,38 @@
+using Apollon.WPF.Stores;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Apollon.WPF.ViewModels
+{
+ public class MainViewModel : ViewModelBase
+ {
+ private readonly ModalNavigationStore _modalNavigationStore;
+
+ public ViewModelBase CurrentModalViewModel => _modalNavigationStore.CurrentViewModel;
+ public bool IsModalOpen => _modalNavigationStore.IsOpen;
+ public OverviewViewModel OverviewViewModel { get; }
+
+ public MainViewModel(ModalNavigationStore modalNavigationStore, OverviewViewModel overviewViewModel)
+ {
+ _modalNavigationStore = modalNavigationStore;
+ OverviewViewModel = overviewViewModel;
+
+ _modalNavigationStore.CurrentViewModelChanged += ModalNavigationStore_CurrentViewModelChanged;
+ }
+
+ protected override void Dispose()
+ {
+ _modalNavigationStore.CurrentViewModelChanged -= ModalNavigationStore_CurrentViewModelChanged;
+ base.Dispose();
+ }
+ private void ModalNavigationStore_CurrentViewModelChanged()
+ {
+ OnPropertyChanged(nameof(CurrentModalViewModel));
+ OnPropertyChanged(nameof(IsModalOpen));
+
+ }
+ }
+}
diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs
index b918cfd..4659c40 100644
--- a/Apollon.WPF/ViewModels/OverviewViewModel.cs
+++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs
@@ -10,14 +10,14 @@ namespace Apollon.WPF.ViewModels
{
public class OverviewViewModel : ViewModelBase
{
- public OverviewListingViewModel ApollonOverviewListingViewModel { get; }
- public OverviewDetailsViewModel ApollonOverviewDetailsViewModel{ get; }
+ public OverviewListingViewModel OverviewListingViewModel { get; }
+ public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
public ICommand AddTournamentCommand { get; }
public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore)
{
- ApollonOverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore);
- ApollonOverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
+ OverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore);
+ OverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
}
}
}
diff --git a/Apollon.WPF/Views/Components/AddEditDetails.xaml b/Apollon.WPF/Views/Components/AddEditDetails.xaml
index ce7b758..cebf2d3 100644
--- a/Apollon.WPF/Views/Components/AddEditDetails.xaml
+++ b/Apollon.WPF/Views/Components/AddEditDetails.xaml
@@ -75,7 +75,8 @@
Height="25"
HorizontalAlignment="Left"
Margin="0 0 80 0"
- IsEnabled="False"/>
+ IsEnabled="{Binding CanSubmit}">
+