about summary refs log tree commit diff
path: root/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs')
-rw-r--r--MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
index d6343e2..92c617b 100644
--- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
+++ b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
@@ -1,4 +1,5 @@
 using Avalonia.Controls;
+using Avalonia.Interactivity;
 using Avalonia.Markup.Xaml;
 
 namespace MatrixRoomUtils.Desktop.Components;
@@ -8,12 +9,24 @@ public partial class NavigationStack : UserControl {
         InitializeComponent();
     }
 
-    private void InitializeComponent() {
-        AvaloniaXamlLoader.Load(this);
+    // private void InitializeComponent() {
+        // AvaloniaXamlLoader.Load(this);
+        // buildView();
+    // }
+
+    protected override void OnLoaded(RoutedEventArgs e) {
+        base.OnLoaded(e);
         buildView();
     }
-
+    
     private void buildView() {
+        if (navPanel is null) {
+            Console.WriteLine("NavigationStack buildView called while navpanel is null!");
+            // await Task.Delay(100);
+            // if (navPanel is null)
+                // await buildView();
+            // else Console.WriteLine("navpanel is not null!");
+        }
         navPanel.Children.Clear();
         foreach (var item in _stack) {
             Button btn = new() {
@@ -25,7 +38,7 @@ public partial class NavigationStack : UserControl {
             };
             navPanel.Children.Add(btn);
         }
-        content = Current?.View ?? new UserControl();
+        content.Content = Current?.View ?? new UserControl();
     }
 
 
@@ -44,13 +57,16 @@ public partial class NavigationStack : UserControl {
             Name = name,
             View = view
         });
+        buildView();
     }
 
     public void Pop() {
         _stack.RemoveAt(_stack.Count - 1);
+        buildView();
     }
 
     public void PopTo(int index) {
         _stack.RemoveRange(index, _stack.Count - index);
+        buildView();
     }
 }