Ethosa 3 years ago
parent
commit
c5776b3cf9
6 changed files with 64 additions and 6 deletions
  1. 2 2
      MainWindow.xaml
  2. 17 3
      MainWindow.xaml.cs
  3. 1 1
      Pages/AuthPage.xaml
  4. 4 0
      Pages/AuthPage.xaml.cs
  5. 14 0
      Pages/Page2.xaml
  6. 26 0
      Pages/Page2.xaml.cs

+ 2 - 2
MainWindow.xaml

@@ -13,7 +13,7 @@
             <RowDefinition Height="42"/>
         </Grid.RowDefinitions>
         <Rectangle Fill="#FFF4F4F5" Grid.Row="2" StrokeThickness="0" Height="42" VerticalAlignment="Center"/>
-        <Button Content="назад" HorizontalAlignment="Left" Margin="18,0,0,0" VerticalAlignment="Center" Height="22" Width="76"/>
-        <Frame x:Name="MainFrame" Source="Pages/AuthPage.xaml" Grid.Row="1" />
+        <Frame x:Name="MainFrame" Source="Pages/AuthPage.xaml" Grid.Row="1" Navigated="MainFrame_Navigated" Foreground="White" />
+        <Button x:Name="ButtonBack" Content="назад" HorizontalAlignment="Left" Margin="10,5,0,5"  Width="76" Click="Button_Click"/>
     </Grid>
 </Window>

+ 17 - 3
MainWindow.xaml.cs

@@ -27,10 +27,24 @@ namespace bebra
 
         private void Button_Click(object sender, RoutedEventArgs e)
         {
-
+            if (MainFrame.CanGoBack) MainFrame.GoBack();
         }
 
-        
+        private void MainFrame_Navigated(object sender, NavigationEventArgs e)
+        {
+            {
+                if (!(e.Content is Page page)) return;
+                this.Title = $"LESSON - {page.Title}";
 
-}
+                if (page is Pages.AuthPage)
+                {
+                    ButtonBack.Visibility = Visibility.Hidden;
+                }
+                else
+                {
+                    ButtonBack.Visibility = Visibility.Visible;
+                }}
+
+        }
+    }
 }

+ 1 - 1
Pages/AuthPage.xaml

@@ -25,7 +25,7 @@
         <Label Content="Пароль" HorizontalAlignment="Center" Margin="0,30,0,0" VerticalAlignment="Top" Height="19" Width="50" Grid.Column="1" Grid.Row="1"/>
         <PasswordBox x:Name="PasswordBox" HorizontalAlignment="Center" Margin="0,30,0,0" Password="" VerticalAlignment="Top" Width="170" Grid.Column="2" Height="19" Grid.Row="1"/>
         <Button Click="ButtonEnter_OnClick" Content="Вход" Grid.Column="2" HorizontalAlignment="Center" Margin="0,72,0,0" Grid.Row="1" VerticalAlignment="Top" Width="170" />
-        <Button Content="Регистрация" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Center" Width="170"/>
+        <Button Content="Регистрация" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Center" Width="170" Click="Button_Click"/>
 
     </Grid>
 </Page>

+ 4 - 0
Pages/AuthPage.xaml.cs

@@ -30,5 +30,9 @@ namespace bebra.Pages
             }
 }
 
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService?.Navigate(new Page2());
+        }
     }
 }

+ 14 - 0
Pages/Page2.xaml

@@ -0,0 +1,14 @@
+<Page x:Class="bebra.Pages.Page2"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:bebra.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="Page2">
+
+    <Grid Background="White">
+        
+    </Grid>
+</Page>

+ 26 - 0
Pages/Page2.xaml.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace bebra.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для Page2.xaml
+    /// </summary>
+    public partial class Page2 : Page
+    {
+        public Page2()
+        {
+            InitializeComponent();
+        }
+    }
+}