Fixed a bug that lead the LandingPage buttons to stop working after navigating back from PeriodicTablePage

This commit is contained in:
OliverT87 2025-06-27 08:47:02 +02:00
parent b35804f547
commit 4485385255

View File

@ -211,23 +211,25 @@ namespace Project_Periodensystem.View
}
/// <summary>
/// Event-Handler für Zurück-Button (falls gewünscht)
/// Event-Handler für Zurück-Button - SAUBERES MVC
/// </summary>
private void BackButton_Click(object? sender, RoutedEventArgs e)
{
try
{
var mainWindow = TopLevel.GetTopLevel(this) as Window;
if (mainWindow != null)
if (_controller != null)
{
var landingPage = new LandingPage();
mainWindow.Content = landingPage;
Logger.Log("Navigation zurück zur Landing Page");
// Controller übernimmt Navigation
_controller.HandleNavigateToLanding();
}
else
{
Logger.LogError("Controller nicht gesetzt - kann nicht navigieren");
}
}
catch (Exception ex)
{
Logger.Log($"Fehler bei Navigation zurück: {ex.Message}");
Logger.LogException(ex, "BackButton_Click");
}
}