From 5554751a27823a11aa0359c5cf8fc4e670ab80d1 Mon Sep 17 00:00:00 2001 From: Fredi Fowler Date: Sat, 12 Jan 2019 20:48:23 +0300 Subject: [PATCH] Fix NavogationButton close method --- LimpStats.Client/CustomControls/NavigateButton.xaml.cs | 6 +++--- LimpStats.Client/MainWindow.xaml.cs | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/LimpStats.Client/CustomControls/NavigateButton.xaml.cs b/LimpStats.Client/CustomControls/NavigateButton.xaml.cs index a92fb37..503f6c8 100644 --- a/LimpStats.Client/CustomControls/NavigateButton.xaml.cs +++ b/LimpStats.Client/CustomControls/NavigateButton.xaml.cs @@ -7,21 +7,21 @@ namespace LimpStats.Client.CustomControls public partial class NavigateButton : UserControl { private readonly IViewNavigateService _navigateService; - private readonly UserControl _currentControl; + public readonly UserControl CurrentControl; public NavigateButton(string viewName, IViewNavigateService navigateService, UserControl block) { InitializeComponent(); _navigateService = navigateService; - _currentControl = block; + CurrentControl = block; OpenViewButton.DataContext = viewName; } private void ShowUserControl(object sender, RoutedEventArgs e) { - _navigateService.OpenView(_currentControl); + _navigateService.OpenView(CurrentControl); } private void RemoveFromListButton(object sender, RoutedEventArgs e) diff --git a/LimpStats.Client/MainWindow.xaml.cs b/LimpStats.Client/MainWindow.xaml.cs index 41fe598..71cfddc 100644 --- a/LimpStats.Client/MainWindow.xaml.cs +++ b/LimpStats.Client/MainWindow.xaml.cs @@ -21,6 +21,10 @@ public MainWindow() public void RemoveButton(NavigateButton button) { NavigatePanel.Children.Remove(button); + if (MainWindowContent.Content == button.CurrentControl.Content) + { + MainWindowContent.Visibility = Visibility.Hidden; + } //TODO: implement closing content window } @@ -31,6 +35,7 @@ public void AddToViewList(string viewTitle, UserControl view) public void OpenView(UserControl view) { + MainWindowContent.Visibility = Visibility.Visible; MainWindowContent.Content = view.Content; }