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