From b0b0b3ee3431b7877a8f376ee65b0e59f317e3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Kub=C3=AD=C4=8Dek?= Date: Sun, 7 Jun 2026 22:07:13 +0200 Subject: [PATCH] =?UTF-8?q?Dod=C4=9Bl=C3=A1n=C3=AD=20aplikace=20podle=20tu?= =?UTF-8?q?tori=C3=A1lu.=20Nyn=C3=AD=20lze=20ulo=C5=BEit,=20smazat=20a=20o?= =?UTF-8?q?tev=C3=ADr=C3=A1t=20r=C5=AFzn=C3=A9=20pozn=C3=A1mky.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- winui-learning/winui-learning/MainWindow.xaml | 6 ++++-- winui-learning/winui-learning/MainWindow.xaml.cs | 10 ++++++++++ .../winui-learning/Views/AllNotesPage.xaml | 7 +++++-- .../winui-learning/Views/AllNotesPage.xaml.cs | 11 +++++++++++ winui-learning/winui-learning/Views/NotePage.xaml | 1 - .../winui-learning/Views/NotePage.xaml.cs | 14 +++++++++++++- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/winui-learning/winui-learning/MainWindow.xaml b/winui-learning/winui-learning/MainWindow.xaml index 672a488..ae61539 100644 --- a/winui-learning/winui-learning/MainWindow.xaml +++ b/winui-learning/winui-learning/MainWindow.xaml @@ -3,7 +3,6 @@ x:Class="winui_learning.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:winui_learning" xmlns:views="using:winui_learning.Views" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -25,7 +24,10 @@ + Title="WinUI Notes" + IsBackButtonVisible="True" + IsBackButtonEnabled="{x:Bind rootFrame.CanGoBack, Mode=OneWay}" + BackRequested="AppTitleBar_BackRequested"> diff --git a/winui-learning/winui-learning/MainWindow.xaml.cs b/winui-learning/winui-learning/MainWindow.xaml.cs index 0bc5dca..7014eba 100644 --- a/winui-learning/winui-learning/MainWindow.xaml.cs +++ b/winui-learning/winui-learning/MainWindow.xaml.cs @@ -1,4 +1,6 @@ +using ABI.Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml; +using TitleBar = Microsoft.UI.Xaml.Controls.TitleBar; // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -16,5 +18,13 @@ public sealed partial class MainWindow : Window ExtendsContentIntoTitleBar = true; SetTitleBar(AppTitleBar); } + + private void AppTitleBar_BackRequested(TitleBar titleBar, object args) + { + if (rootFrame.CanGoBack) + { + rootFrame.GoBack(); + } + } } diff --git a/winui-learning/winui-learning/Views/AllNotesPage.xaml b/winui-learning/winui-learning/Views/AllNotesPage.xaml index 55a27f0..7a67800 100644 --- a/winui-learning/winui-learning/Views/AllNotesPage.xaml +++ b/winui-learning/winui-learning/Views/AllNotesPage.xaml @@ -46,7 +46,7 @@ - + @@ -56,7 +56,10 @@ + ItemTemplate="{StaticResource NoteItemTemplate}" + SelectionMode="None" + IsItemInvokedEnabled="True" + ItemInvoked="ItemsView_ItemInvoked"> diff --git a/winui-learning/winui-learning/Views/NotePage.xaml.cs b/winui-learning/winui-learning/Views/NotePage.xaml.cs index 5a7bc7a..62c0b20 100644 --- a/winui-learning/winui-learning/Views/NotePage.xaml.cs +++ b/winui-learning/winui-learning/Views/NotePage.xaml.cs @@ -1,5 +1,6 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Navigation; using winui_learning.Models; // To learn more about WinUI, the WinUI project structure, @@ -12,13 +13,20 @@ namespace winui_learning.Views /// public sealed partial class NotePage : Page { - private NoteModel? note; + private NoteModel note = new(); public NotePage() { InitializeComponent(); } + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + note = e.Parameter as NoteModel ?? new NoteModel(); + Bindings.Update(); + } + private async void ButtonClick_Save(object sender, RoutedEventArgs e) { if (note is not null) @@ -33,6 +41,10 @@ namespace winui_learning.Views { await note.DeleteAsync(); } + if (Frame.CanGoBack) + { + Frame.GoBack(); + } } } }