[FIX] made mainwindow MVVM

This commit is contained in:
Sem van der Hoeven
2020-10-20 19:25:56 +02:00
parent f1a47b509d
commit 1552479f4d
2 changed files with 17 additions and 16 deletions

View File

@@ -7,6 +7,8 @@ using System.Windows.Input;
using SharedClientServer;
using System.Diagnostics;
using System.Windows;
using System.Collections.ObjectModel;
using Client.Views;
namespace Client
{
@@ -17,16 +19,12 @@ namespace Client
public ICommand OnHostButtonClick { get; set; }
public ICommand JoinSelectedLobby { get; set; }
public Lobby SelectedLobby { get; set; }
public ViewModel()
{
_model = new Model();
ButtonCommand = new RelayCommand(() =>
{
}, true);
_lobbies = new List<Lobby>();
_lobbies = new ObservableCollection<Lobby>();
_lobbies.Add(new Lobby(50, 3, 8));
_lobbies.Add(new Lobby(69, 1, 9));
@@ -39,9 +37,13 @@ namespace Client
JoinSelectedLobby = new RelayCommand(() =>
{
if (SelectedLobby != null)
{
GameWindow window = new GameWindow();
window.Show();
}
Debug.WriteLine("Joining selected lobby");
});
}, true);
}
private void ClickCheck()
@@ -52,7 +54,6 @@ namespace Client
_model.Numbers = _model.Numbers + 5;
}
public ICommand ButtonCommand { get; set; }
private Model _model;
@@ -69,8 +70,8 @@ namespace Client
}
}
private List<Lobby> _lobbies;
public List<Lobby> Lobbies
private ObservableCollection<Lobby> _lobbies;
public ObservableCollection<Lobby> Lobbies
{
get { return _lobbies; }
set { _lobbies = value; }