From b69e05eb285ec70eb4f26a084deb7f9b4db9cceb Mon Sep 17 00:00:00 2001 From: Jumar Macato <16554748+jmacato@users.noreply.github.com> Date: Sat, 4 Apr 2026 01:50:27 +0800 Subject: [PATCH 01/60] Post NSAccessibility notifications for property changes on macOS (#21074) --- native/Avalonia.Native/src/OSX/AvnWindow.mm | 12 +++++++++ native/Avalonia.Native/src/OSX/automation.mm | 28 ++++++++++++++++++-- src/Avalonia.Native/AvnAutomationPeer.cs | 5 ++++ src/Avalonia.Native/avn.idl | 5 ++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/native/Avalonia.Native/src/OSX/AvnWindow.mm b/native/Avalonia.Native/src/OSX/AvnWindow.mm index c4e715229b..b2f20d556b 100644 --- a/native/Avalonia.Native/src/OSX/AvnWindow.mm +++ b/native/Avalonia.Native/src/OSX/AvnWindow.mm @@ -656,6 +656,18 @@ - (void)raisePropertyChanged:(AvnAutomationProperty)property { + switch (property) + { + case AutomationPeer_Name: + NSAccessibilityPostNotification(self, NSAccessibilityTitleChangedNotification); + break; + case AutomationPeer_BoundingRectangle: + NSAccessibilityPostNotification(self, NSAccessibilityMovedNotification); + NSAccessibilityPostNotification(self, NSAccessibilityResizedNotification); + break; + default: + break; + } } @end diff --git a/native/Avalonia.Native/src/OSX/automation.mm b/native/Avalonia.Native/src/OSX/automation.mm index 6eee49f619..412e7ddc5f 100644 --- a/native/Avalonia.Native/src/OSX/automation.mm +++ b/native/Avalonia.Native/src/OSX/automation.mm @@ -488,8 +488,32 @@ - (void)raisePropertyChanged:(AvnAutomationProperty)property { - if (property == AutomationPeer_Name && _peer->GetLiveSetting() != LiveSettingOff) - [self raiseLiveRegionChanged]; + switch (property) + { + case AutomationPeer_Name: + NSAccessibilityPostNotification(self, NSAccessibilityTitleChangedNotification); + if (_peer->GetLiveSetting() != LiveSettingOff) + [self raiseLiveRegionChanged]; + break; + case ValueProvider_Value: + case RangeValueProvider_Value: + NSAccessibilityPostNotification(self, NSAccessibilityValueChangedNotification); + break; + case AutomationPeer_BoundingRectangle: + NSAccessibilityPostNotification(self, NSAccessibilityMovedNotification); + NSAccessibilityPostNotification(self, NSAccessibilityResizedNotification); + break; + case SelectionItemProvider_IsSelected: + case SelectionProvider_Selection: + NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification); + break; + case ToggleProvider_ToggleState: + case ExpandCollapseProvider_ExpandCollapseState: + NSAccessibilityPostNotification(self, NSAccessibilityValueChangedNotification); + break; + default: + break; + } } - (void)raiseLiveRegionChanged diff --git a/src/Avalonia.Native/AvnAutomationPeer.cs b/src/Avalonia.Native/AvnAutomationPeer.cs index 25905da02a..3822864edc 100644 --- a/src/Avalonia.Native/AvnAutomationPeer.cs +++ b/src/Avalonia.Native/AvnAutomationPeer.cs @@ -19,6 +19,11 @@ namespace Avalonia.Native { AutomationElementIdentifiers.ClassNameProperty, AvnAutomationProperty.AutomationPeer_ClassName }, { AutomationElementIdentifiers.NameProperty, AvnAutomationProperty.AutomationPeer_Name }, { RangeValuePatternIdentifiers.ValueProperty, AvnAutomationProperty.RangeValueProvider_Value }, + { ValuePatternIdentifiers.ValueProperty, AvnAutomationProperty.ValueProvider_Value }, + { TogglePatternIdentifiers.ToggleStateProperty, AvnAutomationProperty.ToggleProvider_ToggleState }, + { ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, AvnAutomationProperty.ExpandCollapseProvider_ExpandCollapseState }, + { SelectionItemPatternIdentifiers.IsSelectedProperty, AvnAutomationProperty.SelectionItemProvider_IsSelected }, + { SelectionPatternIdentifiers.SelectionProperty, AvnAutomationProperty.SelectionProvider_Selection }, }; private static readonly ConditionalWeakTable s_wrappers = new(); diff --git a/src/Avalonia.Native/avn.idl b/src/Avalonia.Native/avn.idl index ce9ce0d5b0..b9b5977632 100644 --- a/src/Avalonia.Native/avn.idl +++ b/src/Avalonia.Native/avn.idl @@ -403,6 +403,11 @@ enum AvnAutomationProperty AutomationPeer_ClassName, AutomationPeer_Name, RangeValueProvider_Value, + ValueProvider_Value, + ToggleProvider_ToggleState, + ExpandCollapseProvider_ExpandCollapseState, + SelectionItemProvider_IsSelected, + SelectionProvider_Selection, } struct AvnSize From 1060839683d2f8bb1b752d5bc021a53f90a0129d Mon Sep 17 00:00:00 2001 From: Nathan Nguyen <146415969+NathanDrake2406@users.noreply.github.com> Date: Tue, 7 Apr 2026 03:31:28 +1000 Subject: [PATCH 02/60] Fix access keys not working when KeySymbol is null (#21077) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: add regression test for access key with system key events Regression test for #20961: verifies that access keys fire correctly when triggered via Alt+key (system key events). * fix: provide KeySymbol for system key events via MapVirtualKey On Windows, WM_SYSKEYDOWN (Alt+key) intentionally skips ToUnicodeEx to avoid corrupting keyboard state. This left KeySymbol null, which broke access keys after #20662 switched from Key to KeySymbol. Use MapVirtualKey(VK, MAPVK_VK_TO_CHAR) as a layout-aware fallback for system key events — it resolves the character without touching keyboard state. Fixes #20961 * chore: retrigger CI --- .../Avalonia.Win32/Input/KeyInterop.cs | 18 +++++++++++++ .../Avalonia.Win32/WindowImpl.AppWndProc.cs | 7 +++-- .../Input/AccessKeyHandlerTests.cs | 27 +++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Input/KeyInterop.cs b/src/Windows/Avalonia.Win32/Input/KeyInterop.cs index 834feb861e..f13694e4fb 100644 --- a/src/Windows/Avalonia.Win32/Input/KeyInterop.cs +++ b/src/Windows/Avalonia.Win32/Input/KeyInterop.cs @@ -493,6 +493,24 @@ namespace Avalonia.Win32.Input PhysicalKey.None; } + /// + /// Gets a key symbol from a Windows virtual-key using MapVirtualKey. + /// Unlike , this does not call ToUnicodeEx and is safe to use + /// during WM_SYSKEYDOWN/UP where ToUnicodeEx would corrupt keyboard state. + /// + /// The Windows virtual-key. + /// A key symbol, or null if none matched. + public static string? GetKeySymbolFromVirtualKey(int virtualKey) + { + var ch = MapVirtualKey((uint)virtualKey, (uint)MapVirtualKeyMapTypes.MAPVK_VK_TO_CHAR); + if (ch == 0) + return null; + + // Bit 31 is set for dead keys — strip it to get the base character. + var c = (char)(ch & 0x7FFFFFFF); + return KeySymbolHelper.IsAllowedAsciiKeySymbol(c) ? c.ToString() : null; + } + /// /// Gets a key symbol from a Windows virtual-key and key data. /// diff --git a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs index 82aaac226c..2eba69960b 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs @@ -1446,8 +1446,11 @@ namespace Avalonia.Win32 var physicalKey = KeyInterop.PhysicalKeyFromVirtualKey(virtualKey, keyData); // Avoid calling GetKeySymbol() for WM_SYSKEYDOWN/UP: - // it ultimately calls User32!ToUnicodeEx, which messes up the keyboard state in this case. - var keySymbol = useKeySymbol ? KeyInterop.GetKeySymbol(virtualKey, keyData) : null; + // it ultimately calls ToUnicodeEx, which corrupts keyboard state for system key events. + // Use MapVirtualKey-based fallback instead — it's layout-aware without touching keyboard state. + var keySymbol = useKeySymbol + ? KeyInterop.GetKeySymbol(virtualKey, keyData) + : KeyInterop.GetKeySymbolFromVirtualKey(virtualKey); if (key == Key.None && physicalKey == PhysicalKey.None && string.IsNullOrWhiteSpace(keySymbol)) return null; diff --git a/tests/Avalonia.Base.UnitTests/Input/AccessKeyHandlerTests.cs b/tests/Avalonia.Base.UnitTests/Input/AccessKeyHandlerTests.cs index 9443e22855..166b777ba1 100644 --- a/tests/Avalonia.Base.UnitTests/Input/AccessKeyHandlerTests.cs +++ b/tests/Avalonia.Base.UnitTests/Input/AccessKeyHandlerTests.cs @@ -233,6 +233,33 @@ namespace Avalonia.Base.UnitTests.Input } } + [Fact] + public void Should_Raise_AccessKey_For_System_Key_Event_With_KeySymbol() + { + // Regression test for #20961: on Windows, WM_SYSKEYDOWN (Alt+key) previously + // left KeySymbol null, breaking access keys. MapVirtualKey now provides KeySymbol. + using (UnitTestApplication.Start(TestServices.RealFocus)) + { + var button = new Button(); + var root = new TestRoot(button); + var target = new AccessKeyHandler(); + var raised = 0; + + KeyboardDevice.Instance?.SetFocusedElement(button, NavigationMethod.Unspecified, KeyModifiers.None); + + target.SetOwner(root); + target.Register("F", button); + button.AddHandler(AccessKeyHandler.AccessKeyEvent, (s, e) => ++raised); + + KeyDown(root, Key.LeftAlt); + Assert.Equal(0, raised); + + // MapVirtualKey provides lowercase KeySymbol for system key events + KeyDown(root, Key.F, "f", KeyModifiers.Alt); + Assert.Equal(1, raised); + } + } + [Fact] public void Should_Open_MainMenu_On_Alt_KeyUp() { From 04558f076894382211a6eceecc5e42eb5a06cb91 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Wed, 8 Apr 2026 10:20:53 +0200 Subject: [PATCH 03/60] Master now targets 12.1 --- build/SharedVersion.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/SharedVersion.props b/build/SharedVersion.props index b8c0dd4d43..cff9a24f54 100644 --- a/build/SharedVersion.props +++ b/build/SharedVersion.props @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Avalonia - 12.0.999 + 12.1.999 Avalonia Team Copyright 2013-$([System.DateTime]::Now.ToString(`yyyy`)) © The AvaloniaUI Project https://avaloniaui.net/?utm_source=nuget&utm_medium=referral&utm_content=project_homepage_link From 387c9d96c0dfacaacea3c781256fbad958c5c9b3 Mon Sep 17 00:00:00 2001 From: Dong Bin <14807942+rabbitism@users.noreply.github.com> Date: Wed, 8 Apr 2026 16:08:41 +0800 Subject: [PATCH 04/60] fix(datepicker): fix date picker spacer location. (#21093) --- .../DateTimePickers/DatePickerPresenter.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs b/src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs index bfe928309f..eac695b0b1 100644 --- a/src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs +++ b/src/Avalonia.Controls/DateTimePickers/DatePickerPresenter.cs @@ -457,18 +457,17 @@ namespace Avalonia.Controls } } - ConfigureSpacer(items._firstSpacer, columnIndex > 1); - ConfigureSpacer(items._secondSpacer, columnIndex > 2); + ConfigureSpacer(items._firstSpacer, columnIndex > 1, 1); + ConfigureSpacer(items._secondSpacer, columnIndex > 2, 3); + return; - static void ConfigureSpacer(Control? spacer, bool visible) + static void ConfigureSpacer(Control? spacer, bool visible, int column) { if (spacer == null) return; - // ternary conditional operator is used to make sure grid cells will be validated - Grid.SetColumn(spacer, visible ? 1 : 0); + Grid.SetColumn(spacer, visible ? column : 0); spacer.IsVisible = visible; - } } From 04f9129788fe35148b95a25d82b80e6019f9e373 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Wed, 8 Apr 2026 08:11:01 +0000 Subject: [PATCH 05/60] Update ControlCatalog to use the Page system (#21044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * replace hamburger view with drawer page. use ContentPage in control catalog * Added Icons * fix listbox and carousel page * make MainView drawer page * add PageNavigationHost to control catalog --------- Co-authored-by: Javier Suárez Ruiz --- samples/ControlCatalog/App.xaml | 3 +- samples/ControlCatalog/App.xaml.cs | 37 +- samples/ControlCatalog/Assets/Icon.png | Bin 0 -> 14349 bytes samples/ControlCatalog/ControlCatalog.csproj | 8 +- samples/ControlCatalog/Icons.cs | 194 ++++++++ samples/ControlCatalog/MainView.xaml | 467 ++++++------------ samples/ControlCatalog/MainView.xaml.cs | 97 +++- samples/ControlCatalog/NavHeaderItem.xaml | 101 ++++ .../ControlCatalog/Pages/AcceleratorPage.xaml | 185 +++---- .../Pages/AcceleratorPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/AcrylicPage.xaml | 246 ++++----- .../ControlCatalog/Pages/AcrylicPage.xaml.cs | 2 +- .../Pages/AdornerLayerPage.xaml | 113 +++-- .../Pages/AdornerLayerPage.xaml.cs | 2 +- .../Pages/AutoCompleteBoxPage.xaml | 140 +++--- .../Pages/AutoCompleteBoxPage.xaml.cs | 2 +- .../Pages/BitmapCachePage.axaml | 76 +-- .../Pages/BitmapCachePage.axaml.cs | 4 +- samples/ControlCatalog/Pages/BorderPage.xaml | 112 +++-- .../ControlCatalog/Pages/BorderPage.xaml.cs | 2 +- .../Pages/ButtonSpinnerPage.xaml | 5 +- .../Pages/ButtonSpinnerPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/ButtonsPage.xaml | 13 +- .../ControlCatalog/Pages/ButtonsPage.xaml.cs | 2 +- .../Pages/CalendarDatePickerPage.xaml | 5 +- .../Pages/CalendarDatePickerPage.xaml.cs | 2 +- .../ControlCatalog/Pages/CalendarPage.xaml | 5 +- .../ControlCatalog/Pages/CalendarPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/CanvasPage.xaml | 5 +- .../ControlCatalog/Pages/CanvasPage.xaml.cs | 2 +- .../Pages/CarouselDemoPage.xaml | 21 +- .../Pages/CarouselDemoPage.xaml.cs | 2 +- .../ControlCatalog/Pages/CarouselPage.xaml | 5 +- .../ControlCatalog/Pages/CarouselPage.xaml.cs | 2 +- .../ControlCatalog/Pages/CheckBoxPage.xaml | 5 +- .../ControlCatalog/Pages/CheckBoxPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ClipboardPage.xaml | 5 +- .../Pages/ClipboardPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ColorPickerPage.xaml | 9 +- .../Pages/ColorPickerPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ComboBoxPage.xaml | 4 +- .../ControlCatalog/Pages/ComboBoxPage.xaml.cs | 2 +- .../ControlCatalog/Pages/CommandBarPage.xaml | 13 +- .../Pages/CommandBarPage.xaml.cs | 2 +- .../Pages/CompositionPage.axaml | 121 +++-- .../Pages/CompositionPage.axaml.cs | 2 +- .../Pages/ConnectedAnimationDemoPage.xaml | 7 +- .../Pages/ConnectedAnimationDemoPage.xaml.cs | 2 +- .../Pages/ContainerQueryPage.xaml | 5 +- .../Pages/ContainerQueryPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ContentDemoPage.xaml | 21 +- .../Pages/ContentDemoPage.xaml.cs | 2 +- .../Pages/ContextFlyoutPage.xaml | 9 +- .../Pages/ContextFlyoutPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ContextMenuPage.xaml | 5 +- .../Pages/ContextMenuPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/CursorPage.xaml | 5 +- .../ControlCatalog/Pages/CursorPage.xaml.cs | 2 +- .../ControlCatalog/Pages/CustomDrawing.xaml | 9 +- .../Pages/CustomDrawing.xaml.cs | 2 +- .../ControlCatalog/Pages/DataGridPage.xaml | 5 +- .../ControlCatalog/Pages/DataGridPage.xaml.cs | 2 +- .../Pages/DataValidationPage.axaml | 9 +- .../Pages/DataValidationPage.axaml.cs | 2 +- .../Pages/DateTimePickerPage.xaml | 5 +- .../Pages/DateTimePickerPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/DialogsPage.xaml | 5 +- .../ControlCatalog/Pages/DialogsPage.xaml.cs | 2 +- .../ControlCatalog/Pages/DragAndDropPage.xaml | 9 +- .../Pages/DragAndDropPage.xaml.cs | 2 +- .../ControlCatalog/Pages/DrawerDemoPage.xaml | 21 +- .../Pages/DrawerDemoPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ExpanderPage.xaml | 5 +- .../ControlCatalog/Pages/ExpanderPage.xaml.cs | 2 +- .../ControlCatalog/Pages/FlyoutsPage.axaml | 9 +- .../ControlCatalog/Pages/FlyoutsPage.axaml.cs | 2 +- samples/ControlCatalog/Pages/FocusPage.xaml | 5 +- .../ControlCatalog/Pages/FocusPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/GesturePage.xaml | 21 +- .../{GesturePage.cs => GesturePage.xaml.cs} | 2 +- .../Pages/HeaderedContentPage.axaml | 5 +- .../Pages/HeaderedContentPage.axaml.cs | 2 +- samples/ControlCatalog/Pages/ImagePage.xaml | 5 +- .../ControlCatalog/Pages/ImagePage.xaml.cs | 2 +- samples/ControlCatalog/Pages/LabelsPage.axaml | 9 +- .../ControlCatalog/Pages/LabelsPage.axaml.cs | 2 +- .../Pages/LayoutTransformControlPage.xaml | 5 +- .../Pages/LayoutTransformControlPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/ListBoxPage.xaml | 5 +- .../ControlCatalog/Pages/ListBoxPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/MenuPage.xaml | 5 +- samples/ControlCatalog/Pages/MenuPage.xaml.cs | 2 +- .../ControlCatalog/Pages/NativeEmbedPage.xaml | 5 +- .../Pages/NativeEmbedPage.xaml.cs | 2 +- .../Pages/NavigationDemoPage.xaml | 21 +- .../Pages/NavigationDemoPage.xaml.cs | 2 +- .../Pages/NotificationsPage.xaml | 5 +- .../Pages/NotificationsPage.xaml.cs | 2 +- .../Pages/NumericUpDownPage.xaml | 5 +- .../Pages/NumericUpDownPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/OpenGlPage.xaml | 5 +- .../ControlCatalog/Pages/OpenGlPage.xaml.cs | 2 +- .../ControlCatalog/Pages/PipsPagerPage.xaml | 21 +- .../Pages/PipsPagerPage.xaml.cs | 2 +- .../Pages/PlatformInfoPage.xaml | 5 +- .../Pages/PlatformInfoPage.xaml.cs | 2 +- .../ControlCatalog/Pages/PointersPage.xaml | 23 +- .../ControlCatalog/Pages/PointersPage.xaml.cs | 2 +- .../ControlCatalog/Pages/ProgressBarPage.xaml | 12 +- .../Pages/ProgressBarPage.xaml.cs | 2 +- .../ControlCatalog/Pages/RadioButtonPage.xaml | 5 +- .../Pages/RadioButtonPage.xaml.cs | 2 +- .../Pages/RefreshContainerPage.axaml | 5 +- .../Pages/RefreshContainerPage.axaml.cs | 2 +- .../Pages/RelativePanelPage.axaml | 5 +- .../Pages/RelativePanelPage.axaml.cs | 2 +- samples/ControlCatalog/Pages/ScreenPage.cs | 2 +- .../Pages/ScrollViewerPage.xaml | 15 +- .../Pages/ScrollViewerPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/SliderPage.xaml | 5 +- .../ControlCatalog/Pages/SliderPage.xaml.cs | 2 +- .../ControlCatalog/Pages/SplitViewPage.xaml | 5 +- .../Pages/SplitViewPage.xaml.cs | 2 +- .../ControlCatalog/Pages/TabControlPage.xaml | 5 +- .../Pages/TabControlPage.xaml.cs | 2 +- .../ControlCatalog/Pages/TabStripPage.xaml | 5 +- .../ControlCatalog/Pages/TabStripPage.xaml.cs | 2 +- .../ControlCatalog/Pages/TabbedDemoPage.xaml | 21 +- .../Pages/TabbedDemoPage.xaml.cs | 2 +- .../ControlCatalog/Pages/TextBlockPage.xaml | 5 +- .../Pages/TextBlockPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/TextBoxPage.xaml | 5 +- .../ControlCatalog/Pages/TextBoxPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/ThemePage.axaml | 9 +- .../ControlCatalog/Pages/ThemePage.axaml.cs | 2 +- .../Pages/ToggleSwitchPage.xaml | 25 +- .../Pages/ToggleSwitchPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/ToolTipPage.xaml | 7 +- .../ControlCatalog/Pages/ToolTipPage.xaml.cs | 2 +- .../TransitioningContentControlPage.axaml | 17 +- .../TransitioningContentControlPage.axaml.cs | 2 +- .../ControlCatalog/Pages/TreeViewPage.xaml | 5 +- .../ControlCatalog/Pages/TreeViewPage.xaml.cs | 2 +- samples/ControlCatalog/Pages/ViewboxPage.xaml | 5 +- .../ControlCatalog/Pages/ViewboxPage.xaml.cs | 2 +- .../Pages/WindowCustomizationsPage.xaml | 5 +- .../Pages/WindowCustomizationsPage.xaml.cs | 2 +- samples/ControlCatalog/ScrollPage.xaml | 34 ++ .../ViewModels/MainWindowViewModel.cs | 11 +- .../MainWindowViewModel_PageList.cs | 196 ++++++++ .../HamburgerMenu/HamburgerMenu.xaml | 8 +- 151 files changed, 1703 insertions(+), 1128 deletions(-) create mode 100644 samples/ControlCatalog/Assets/Icon.png create mode 100644 samples/ControlCatalog/Icons.cs create mode 100644 samples/ControlCatalog/NavHeaderItem.xaml rename samples/ControlCatalog/Pages/{GesturePage.cs => GesturePage.xaml.cs} (96%) create mode 100644 samples/ControlCatalog/ScrollPage.xaml create mode 100644 samples/ControlCatalog/ViewModels/MainWindowViewModel_PageList.cs diff --git a/samples/ControlCatalog/App.xaml b/samples/ControlCatalog/App.xaml index 179f64233e..6ab30cc180 100644 --- a/samples/ControlCatalog/App.xaml +++ b/samples/ControlCatalog/App.xaml @@ -8,7 +8,8 @@ - + + diff --git a/samples/ControlCatalog/App.xaml.cs b/samples/ControlCatalog/App.xaml.cs index f14fbb1fa3..71e4113a3a 100644 --- a/samples/ControlCatalog/App.xaml.cs +++ b/samples/ControlCatalog/App.xaml.cs @@ -18,7 +18,7 @@ namespace ControlCatalog private FluentTheme? _fluentTheme; private SimpleTheme? _simpleTheme; private IStyle? _colorPickerFluent, _colorPickerSimple; - + public App() { DataContext = new ApplicationViewModel(); @@ -34,7 +34,7 @@ namespace ControlCatalog _simpleTheme = (SimpleTheme)Resources["SimpleTheme"]!; _colorPickerFluent = (IStyle)Resources["ColorPickerFluent"]!; _colorPickerSimple = (IStyle)Resources["ColorPickerSimple"]!; - + SetCatalogThemes(CatalogTheme.Fluent); } @@ -44,16 +44,22 @@ namespace ControlCatalog { desktopLifetime.MainWindow = new MainWindow { DataContext = new MainWindowViewModel() }; } - else if(ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime) + else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime) { - singleViewFactoryApplicationLifetime.MainViewFactory = () => new MainView { DataContext = new MainWindowViewModel() }; + singleViewFactoryApplicationLifetime.MainViewFactory = () => new PageNavigationHost() + { + Page = new MainView { DataContext = new MainWindowViewModel() } + }; } else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) { - singleViewLifetime.MainView = new MainView { DataContext = new MainWindowViewModel() }; + singleViewLifetime.MainView = new PageNavigationHost() + { + Page = new MainView { DataContext = new MainWindowViewModel() } + }; } - if (this.TryGetFeature() is {} activatableApplicationLifetime) + if (this.TryGetFeature() is { } activatableApplicationLifetime) { activatableApplicationLifetime.Activated += (sender, args) => Console.WriteLine($"App activated: {args.Kind}"); @@ -99,14 +105,14 @@ namespace ControlCatalog } private CatalogTheme _prevTheme; - public static CatalogTheme CurrentTheme => ((App)Current!)._prevTheme; + public static CatalogTheme CurrentTheme => ((App)Current!)._prevTheme; public static void SetCatalogThemes(CatalogTheme theme) { var app = (App)Current!; var prevTheme = app._prevTheme; app._prevTheme = theme; var shouldReopenWindow = prevTheme != theme; - + if (app._themeStylesContainer.Count == 0) { app._themeStylesContainer.Add(new Style()); @@ -130,18 +136,27 @@ namespace ControlCatalog if (app.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) { var oldWindow = desktopLifetime.MainWindow; - var newWindow = new MainWindow(); + var newWindow = new MainWindow() + { + DataContext = new MainWindowViewModel() + }; desktopLifetime.MainWindow = newWindow; newWindow.Show(); oldWindow?.Close(); } else if (app.ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime) { - singleViewFactoryApplicationLifetime.MainViewFactory = () => new MainView { DataContext = new MainWindowViewModel() }; + singleViewFactoryApplicationLifetime.MainViewFactory = () => new PageNavigationHost() + { + Page = new MainView { DataContext = new MainWindowViewModel() } + }; } else if (app.ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) { - singleViewLifetime.MainView = new MainView(); + singleViewLifetime.MainView = new PageNavigationHost() + { + Page = new MainView { DataContext = new MainWindowViewModel() } + }; } } } diff --git a/samples/ControlCatalog/Assets/Icon.png b/samples/ControlCatalog/Assets/Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..41a2a618fb02e4cb7f6a15caf572b693bfe1ebb1 GIT binary patch literal 14349 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 + @@ -38,7 +39,12 @@ - + + + + + MSBuild:Compile + diff --git a/samples/ControlCatalog/Icons.cs b/samples/ControlCatalog/Icons.cs new file mode 100644 index 0000000000..58d0e0b7d4 --- /dev/null +++ b/samples/ControlCatalog/Icons.cs @@ -0,0 +1,194 @@ +namespace ControlCatalog +{ + internal static class Icons + { + // Layers/Composition + public const string Layers = "M12,16L19.36,10.27L21,9L12,2L3,9L4.63,10.27M12,18.54L4.62,12.81L3,14.07L12,21.07L21,14.07L19.37,12.8"; + + // Keyboard + public const string Keyboard = "M19,10H17V8H19M19,13H17V11H19M16,10H14V8H16M16,13H14V11H16M16,17H8V15H16M7,10H5V8H7M7,13H5V11H7M8,11H10V13H8M8,8H10V10H8M11,11H13V13H11M11,8H13V10H11M20,5H4C2.89,5 2,5.89 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7C22,5.89 21.1,5 20,5Z"; + + // Blur/Acrylic + public const string Blur = "M14.5,10C16.43,10 18,8.43 18,6.5C18,4.57 16.43,3 14.5,3C12.57,3 11,4.57 11,6.5C11,8.43 12.57,10 14.5,10M14.5,4A2.5,2.5 0 0,1 17,6.5A2.5,2.5 0 0,1 14.5,9A2.5,2.5 0 0,1 12,6.5A2.5,2.5 0 0,1 14.5,4M8.5,14C10.43,14 12,12.43 12,10.5C12,8.57 10.43,7 8.5,7C6.57,7 5,8.57 5,10.5C5,12.43 6.57,14 8.5,14M8.5,8A2.5,2.5 0 0,1 11,10.5A2.5,2.5 0 0,1 8.5,13A2.5,2.5 0 0,1 6,10.5A2.5,2.5 0 0,1 8.5,8M14.5,16A4.5,4.5 0 0,0 10,20.5A4.5,4.5 0 0,0 14.5,25A4.5,4.5 0 0,0 19,20.5A4.5,4.5 0 0,0 14.5,16M14.5,24A3.5,3.5 0 0,1 11,20.5A3.5,3.5 0 0,1 14.5,17A3.5,3.5 0 0,1 18,20.5A3.5,3.5 0 0,1 14.5,24Z"; + + // Adorner/Sparkle + public const string Sparkle = "M12,1L9,9L1,12L9,15L12,23L15,15L23,12L15,9"; + + // Text/AutoComplete + public const string TextInput = "M20,21H4V3H20V21M6,9H14V7H6V9M6,13H18V11H6V13M6,17H14V15H6V17Z"; + + // Border/Square + public const string Border = "M4,4H20V20H4V4M6,8V6H8V8H6M6,12V10H8V12H6M6,16V14H8V16H6M6,20V18H8V20H6M10,20V18H12V20H10M14,20V18H16V20H14M18,20V18H20V20H18M18,16V14H20V16H18M18,12V10H20V12H18M18,8V6H20V8H18M14,8V6H16V8H14M10,8V6H12V8H10Z"; + + // Lightning/Cache + public const string Lightning = "M11,21H7L13,3H17L14,10H20L11,21Z"; + + // Cursor Click/Button + public const string CursorClick = "M10.76,8.69A0.76,0.76 0 0,0 10,9.45V20.9C10,21.32 10.34,21.66 10.76,21.66C10.95,21.66 11.11,21.6 11.24,21.5L13.15,19.95L14.81,23.57C14.94,23.84 15.21,24 15.5,24C15.62,24 15.74,23.97 15.85,23.92L17.28,23.26C17.69,23.07 17.86,22.59 17.66,22.17L16,18.54L18.44,18.19C18.87,18.13 19.1,17.73 18.91,17.37L12.1,8.89C11.95,8.76 11.79,8.69 10.76,8.69M15,10V8H20V10H15M13.83,4.76L16.66,1.93L18.07,3.34L15.24,6.17L13.83,4.76M10,0V5H8V0H10M3.93,14.66L6.76,11.83L8.17,13.24L5.34,16.07L3.93,14.66M3.93,3.34L5.34,1.93L8.17,4.76L6.76,6.17L3.93,3.34M7,10H2V8H7V10Z"; + + // Spinner/ButtonSpinner + public const string Spinner = "M12,4V2A10,10 0 0,0 2,12H4A8,8 0 0,1 12,4Z"; + + // Calendar + public const string Calendar = "M19,19H5V8H19M16,1V3H8V1H6V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3H18V1M9,15H7V13H9V15M13,15H11V13H13V15M17,15H15V13H17V15M9,11H7V9H9V11M13,11H11V9H13V11M17,11H15V9H17V11Z"; + + // Canvas/Artboard + public const string Canvas = "M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z"; + + // Command/Terminal + public const string Terminal = "M20,19V7H4V19H20M20,3A2,2 0 0,1 22,5V19A2,2 0 0,1 20,21H4A2,2 0 0,1 2,19V5C2,3.89 2.9,3 4,3H20M13,17V15H18V17H13M9.58,13L5.57,9H8.4L11.7,12.3C12.09,12.69 12.09,13.33 11.7,13.72L8.42,17H5.59L9.58,13Z"; + + // Slides/Carousel + public const string Slides = "M2,6H6V18H2V6M7,6H17V18H7V6M18,6H22V18H18V6Z"; + + // Checkbox + public const string Checkbox = "M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8"; + + // Clipboard + public const string Clipboard = "M19,3H14.82C14.4,1.84 13.3,1 12,1C10.7,1 9.6,1.84 9.18,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3"; + + // Palette/Color + public const string Palette = "M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12Z"; + + // Dropdown/ComboBox + public const string Dropdown = "M7,10L12,15L17,10H7Z"; + + // Container/Box + public const string Container = "M2,2H8V4H16V2H22V8H20V16H22V22H16V20H8V22H2V16H4V8H2V2M16,8V6H8V8H6V16H8V18H16V16H18V8H16M4,4V6H6V4H4M18,4V6H20V4H18M4,18V20H6V18H4M18,18V20H20V18H18Z"; + + // Document/Page + public const string Document = "M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z"; + + // Menu/Context + public const string Menu = "M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z"; + + // Cursor/Pointer + public const string Cursor = "M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.39,12.92 18.83,13.03L14.83,13.78L17,18.5C17.24,19 17,19.59 16.5,19.83L13.64,21.97Z"; + + // Brush/Drawing + public const string Brush = "M20.71,4.63L19.37,3.29C19,2.9 18.35,2.9 17.96,3.29L9,12.25L11.75,15L20.71,6.04C21.1,5.65 21.1,5 20.71,4.63M7,14A3,3 0 0,0 4,17C4,18.31 2.84,19 2,19C2.92,20.22 4.5,21 6,21A4,4 0 0,0 10,17A3,3 0 0,0 7,14Z"; + + // Grid/Table + public const string Grid = "M10,4V8H14V4H10M16,4V8H20V4H16M16,10V14H20V10H16M16,16V20H20V16H16M14,20V16H10V20H14M8,20V16H4V20H8M8,14V10H4V14H8M8,8V4H4V8H8M10,14H14V10H10V14Z"; + + // Shield/Validation + public const string Shield = "M10,17L6,13L7.41,11.59L10,14.17L16.59,7.58L18,9M12,1L3,5V11C3,16.55 6.84,21.74 12,23C17.16,21.74 21,16.55 21,11V5L12,1Z"; + + // Clock + public const string Clock = "M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M16.2,16.2L11,13V7H12.5V12.2L17,14.9L16.2,16.2Z"; + + // Dialog/Message + public const string Dialog = "M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2Z"; + + // DragDrop/Move + public const string DragDrop = "M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"; + + // Sidebar/Drawer + public const string Drawer = "M3,2H21A1,1 0 0,1 22,3V21A1,1 0 0,1 21,22H3A1,1 0 0,1 2,21V3A1,1 0 0,1 3,2M10,4V20H20V4H10M4,4V20H8V4H4Z"; + + // Expand + public const string Expand = "M10,21V19H6.41L10.91,14.5L9.5,13.09L5,17.59V14H3V21H10M14.5,10.91L19,6.41V10H21V3H14V5H17.59L13.09,9.5L14.5,10.91Z"; + + // Flyout/Popup + public const string Flyout = "M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M7,9H10V7H7V9M7,13H17V11H7V13M7,17H14V15H7V17Z"; + + // Target/Focus + public const string Target = "M12,8A4,4 0 0,0 8,12A4,4 0 0,0 12,16A4,4 0 0,0 16,12A4,4 0 0,0 12,8M3.05,13H1V11H3.05C3.5,6.83 6.83,3.5 11,3.05V1H13V3.05C17.17,3.5 20.5,6.83 20.95,11H23V13H20.95C20.5,17.17 17.17,20.5 13,20.95V23H11V20.95C6.83,20.5 3.5,17.17 3.05,13M12,5A7,7 0 0,0 5,12A7,7 0 0,0 12,19A7,7 0 0,0 19,12A7,7 0 0,0 12,5Z"; + + // Gesture/Touch + public const string Gesture = "M5,15A2,2 0 0,0 3,17V19H7V17A2,2 0 0,0 5,15M5,11A6,6 0 0,0 -1,17H1A4,4 0 0,1 5,13V11M5,7C0.03,7 -4,11.03 -4,16V17H-2V16C-2,12.13 1.13,9 5,9V7M20.5,9.5L12,18L8.5,14.5L7.08,15.91L12,20.84L21.92,10.91L20.5,9.5Z"; + + // Image/Photo + public const string Image = "M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z"; + + // Tag/Label + public const string Tag = "M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.45 21.77,11.95 21.41,11.58Z"; + + // Transform/Rotate + public const string Transform = "M16.89,15.5L18.31,16.89C19.21,15.73 19.76,14.39 19.93,13H17.91C17.77,13.87 17.43,14.72 16.89,15.5M13,17.9V19.92C14.39,19.75 15.74,19.21 16.9,18.31L15.46,16.87C14.71,17.41 13.87,17.76 13,17.9M19.93,11C19.76,9.61 19.21,8.27 18.31,7.11L16.89,8.53C17.43,9.28 17.77,10.13 17.91,11M15.55,5.55L11,1V5.07C7.06,5.56 4,8.92 4,12.95C4,17.18 7.32,20.56 11.46,20.93C11.64,20.95 11.82,20.97 12,20.97C12.18,20.97 12.36,20.95 12.54,20.93C12.69,20.92 12.83,20.89 13,20.87V18.9C12.82,18.92 12.65,18.95 12.47,18.95C12.32,18.96 12.16,18.97 12,18.97C8.42,18.97 5.53,16.12 5.53,12.58C5.53,9.36 7.88,6.67 11,6.15V10L15.55,5.55Z"; + + // List + public const string List = "M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z"; + + // Bell/Notification + public const string Bell = "M21,19V20H3V19L5,17V11C5,7.9 7.03,5.17 10,4.29C10,4.19 10,4.1 10,4A2,2 0 0,1 12,2A2,2 0 0,1 14,4C14,4.1 14,4.19 14,4.29C16.97,5.17 19,7.9 19,11V17L21,19M14,21A2,2 0 0,1 12,23A2,2 0 0,1 10,21"; + + // Number/Hash + public const string Number = "M5.41,21L6.12,17H2.12L2.47,15H6.47L7.53,9H3.53L3.88,7H7.88L8.59,3H10.59L9.88,7H15.88L16.59,3H18.59L17.88,7H21.88L21.53,9H17.53L16.47,15H20.47L20.12,17H16.12L15.41,21H13.41L14.12,17H8.12L7.41,21H5.41M9.47,9L8.41,15H14.41L15.47,9H9.47Z"; + + // Cube/3D + public const string Cube = "M21,16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V7.5C3,7.12 3.21,6.79 3.53,6.62L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.79,6.79 21,7.12 21,7.5V16.5M12,4.15L5,8.09V15.91L12,19.85L19,15.91V8.09L12,4.15Z"; + + // Dots/Pagination + public const string Dots = "M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z"; + + // Info/Information + public const string Info = "M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"; + + // Progress/Loading + public const string Progress = "M13,2.03V2.05L13,4.05C17.39,4.59 20.5,8.58 19.96,12.97C19.5,16.61 16.64,19.5 13,19.93V21.93C18.5,21.38 22.5,16.5 21.95,11C21.5,6.25 17.73,2.5 13,2.03M11,2.06C9.05,2.25 7.19,3 5.67,4.26L7.1,5.74C8.22,4.84 9.57,4.26 11,4.06V2.06M4.26,5.67C3,7.19 2.25,9.04 2.05,11H4.05C4.24,9.58 4.8,8.23 5.69,7.1L4.26,5.67M2.06,13C2.26,14.96 3.03,16.81 4.27,18.33L5.69,16.9C4.81,15.77 4.24,14.42 4.06,13H2.06M7.1,18.37L5.67,19.74C7.18,21 9.04,21.79 11,22V20C9.58,19.82 8.23,19.25 7.1,18.37Z"; + + // Radio + public const string Radio = "M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,7A5,5 0 0,0 7,12A5,5 0 0,0 12,17A5,5 0 0,0 17,12A5,5 0 0,0 12,7Z"; + + // Refresh + public const string Refresh = "M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z"; + + // Layout/Grid + public const string Layout = "M19,11H13V5H19M19,19H13V13H19M11,11H5V5H11M11,19H5V13H11M3,3V21H21V3"; + + // Scroll + public const string Scroll = "M15,20H9V12H4.16L12,4.16L19.84,12H15V20Z"; + + // Slider/Tune + public const string Slider = "M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z"; + + // Split/SplitView + public const string Split = "M18,4H6C4.89,4 4,4.89 4,6V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18V6C20,4.89 19.1,4 18,4M18,6V18H13V6H18Z"; + + // Tab + public const string Tab = "M21,3H3C1.89,3 1,3.89 1,5V19A2,2 0 0,0 3,21H21C22.1,21 23,20.1 23,19V5C23,3.89 22.1,3 21,3M21,19H3V5H13V9H21V19Z"; + + // Theme/Palette + public const string Theme = "M12,18V6A6,6 0 0,1 18,12A6,6 0 0,1 12,18M20,15.31L23.31,12L20,8.69V4H15.31L12,0.69L8.69,4H4V8.69L0.69,12L4,15.31V20H8.69L12,23.31L15.31,20H20V15.31Z"; + + // Toggle/Switch + public const string Toggle = "M17,7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7M17,15A3,3 0 0,1 14,12A3,3 0 0,1 17,9A3,3 0 0,1 20,12A3,3 0 0,1 17,15Z"; + + // Tooltip/Info bubble + public const string Tooltip = "M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M11,15H13V13H11V15M11,11H13V5H11V11Z"; + + // Animation/Transition + public const string Transition = "M2,5.27L3.28,4L20,20.72L18.73,22L12.73,16H7V19L3,15L7,11V14H9.73L5,9.27V14H3V5.27M21,9L17,5V8H14V10H17V13L21,9M17,17V14H15V17H17Z"; + + // Tree/Hierarchy + public const string Tree = "M15,20A1,1 0 0,0 16,19V4H8V19A1,1 0 0,0 9,20H2V22H22V20H15Z"; + + // Viewbox/Resize + public const string Viewbox = "M5,15H3V19A2,2 0 0,0 5,21H9V19H5M5,5H9V3H5A2,2 0 0,0 3,5V9H5M19,3H15V5H19V9H21V5A2,2 0 0,0 19,3M19,19H15V21H19A2,2 0 0,0 21,19V15H19"; + + // Puzzle/Embed + public const string Puzzle = "M20.5,11H19V7C19,5.89 18.1,5 17,5H13V3.5A2.5,2.5 0 0,0 10.5,1A2.5,2.5 0 0,0 8,3.5V5H4A2,2 0 0,0 2,7V10.8H3.5C5.04,10.8 6.2,11.96 6.2,13.5C6.2,15.04 5.04,16.2 3.5,16.2H2V20A2,2 0 0,0 4,22H7.8V20.5C7.8,18.96 8.96,17.8 10.5,17.8C12.04,17.8 13.2,18.96 13.2,20.5V22H17A2,2 0 0,0 19,20V16H20.5A2.5,2.5 0 0,0 23,13.5A2.5,2.5 0 0,0 20.5,11Z"; + + // Window/Application + public const string Window = "M4,4H20V20H4V4M6,8V18H18V8H6Z"; + + // Header/Title + public const string Header = "M3,4H5V10H9V4H11V18H9V12H5V18H3V4M13,8H15.31L15.63,5H17.63L17.31,8H19.31L19.63,5H21.63L21.31,8H23V10H21.1L20.9,12H23V14H20.69L20.37,17H18.37L18.69,14H16.69L16.37,17H14.37L14.69,14H13V12H14.9L15.1,10H13V8M17.1,10L16.9,12H18.9L19.1,10H17.1Z"; + + // Monitor/Screen + public const string Monitor = "M21,16H3V4H21M21,2H3C1.89,2 1,2.89 1,4V16A2,2 0 0,0 3,18H10V20H8V22H16V20H14V18H21A2,2 0 0,0 23,16V4C23,2.89 22.1,2 21,2Z"; + + // Navigation/Compass + public const string Navigation = "M12,2L4.5,20.29L5.21,21L12,18L18.79,21L19.5,20.29L12,2Z"; + + // OpenGL/3D Box (same as Cube but outline variant) + public const string Cube3D = "M21,16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V7.5C3,7.12 3.21,6.79 3.53,6.62L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.79,6.79 21,7.12 21,7.5V16.5M12,4.15L6.04,7.5L12,10.85L17.96,7.5L12,4.15M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V9.21L13,12.58V19.29L19,15.91Z"; + + // Horizontal dots/Pager + public const string HorizontalDots = "M16,12A2,2 0 0,1 18,10A2,2 0 0,1 20,12A2,2 0 0,1 18,14A2,2 0 0,1 16,12M10,12A2,2 0 0,1 12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12M4,12A2,2 0 0,1 6,10A2,2 0 0,1 8,12A2,2 0 0,1 6,14A2,2 0 0,1 4,12Z"; + + // Slider tune/adjust + public const string Tune = "M3,17V19H9V17H3M3,5V7H13V5H3M13,21V19H21V17H13V15H11V21H13M7,9V11H3V13H7V15H9V9H7M21,13V11H11V13H21M15,9H17V7H21V5H17V3H15V9Z"; + } +} diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 3a6d57801a..ea71773d13 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -1,312 +1,157 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + 20 + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + BorderOnly + Full + + + + + Default + Light + Dark + + + + + Fluent + Simple + + + + + None + Transparent + Blur + AcrylicBlur + Mica + + + + + LeftToRight + RightToLeft + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - None - BorderOnly - Full - - - - - Default - Light - Dark - - - - - Fluent - Simple - - - - - None - Transparent - Blur - AcrylicBlur - Mica - - - - - LeftToRight - RightToLeft - - - - - - - - - + + diff --git a/samples/ControlCatalog/MainView.xaml.cs b/samples/ControlCatalog/MainView.xaml.cs index 82172a8ec4..5ad85da149 100644 --- a/samples/ControlCatalog/MainView.xaml.cs +++ b/samples/ControlCatalog/MainView.xaml.cs @@ -10,13 +10,80 @@ using ControlCatalog.ViewModels; namespace ControlCatalog { - public partial class MainView : UserControl + public partial class MainView : DrawerPage { private Action? _disposeTransparencySetters; public MainView() { InitializeComponent(); + + Loaded += MainView_Loaded; + Unloaded += MainView_Unloaded; + } + + private const double WideBreakpoint = 1008; + private const double NarrowBreakpoint = 640; + + private void MainView_Loaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e) + { + if (DataContext == null) + return; + + SizeChanged += OnDrawerSizeChanged; + UpdateAdaptiveLayout(); + } + + private void MainView_Unloaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e) + { + SizeChanged -= OnDrawerSizeChanged; + _lastAppliedMode = null; + } + + private SplitViewDisplayMode? _lastAppliedMode; + private bool _updatingLayout; + + private void OnDrawerSizeChanged(object? sender, SizeChangedEventArgs e) + { + if (e.WidthChanged) + UpdateAdaptiveLayout(); + } + + private void UpdateAdaptiveLayout() + { + if (_updatingLayout || DataContext == null) + return; + + var width = Bounds.Width; + if (width <= 0) + return; + + SplitViewDisplayMode targetMode; + if (width >= WideBreakpoint) + targetMode = SplitViewDisplayMode.Inline; + else if (width >= NarrowBreakpoint) + targetMode = SplitViewDisplayMode.CompactInline; + else + targetMode = SplitViewDisplayMode.Overlay; + + if (_lastAppliedMode == targetMode) + return; + + _updatingLayout = true; + try + { + _lastAppliedMode = targetMode; + ViewModel.DisplayMode = targetMode; + + if (targetMode == SplitViewDisplayMode.Inline) + ViewModel.IsDrawerOpened = true; + else if (targetMode == SplitViewDisplayMode.Overlay) + ViewModel.IsDrawerOpened = false; + } + finally + { + _updatingLayout = false; + } } private void Themes_SelectionChanged(object? sender, SelectionChangedEventArgs e) @@ -66,22 +133,38 @@ namespace ControlCatalog var semiTransparentBrush = new ImmutableSolidColorBrush(Colors.Gray, 0.2); _disposeTransparencySetters = (Action)topLevel.SetValue(BackgroundProperty, transparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose + - Sidebar.SetValue(BackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose + - Sidebar.SetValue(SplitView.PaneBackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose; + SetValue(BackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose + + SetValue(DrawerPage.DrawerBackgroundProperty, semiTransparentBrush, Avalonia.Data.BindingPriority.Style)!.Dispose; } } } + protected override void OnDataContextChanged(EventArgs e) + { + base.OnDataContextChanged(e); + + if (ViewModel != null) + { + ViewModel.Navigator = NavPage; + } + } + internal MainWindowViewModel ViewModel => (MainWindowViewModel)DataContext!; protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); - if (TopLevel.GetTopLevel(this) is Window window) - Decorations.SelectedIndex = (int)window.WindowDecorations; + if (DataContext == null) + return; - var insets = TopLevel.GetTopLevel(this)!.InsetsManager; + UpdateAdaptiveLayout(); + + var topLevel = TopLevel.GetTopLevel(this)!; + if (topLevel is Window window) + ViewModel.SelectedDecorationIndex = (int)window.WindowDecorations; + + var insets = topLevel.InsetsManager; if (insets != null) { // In real life application these events should be unsubscribed to avoid memory leaks. @@ -111,6 +194,8 @@ namespace ControlCatalog ViewModel.IsSystemBarVisible = insets.IsSystemBarVisible ?? true; }; } + + ViewModel.SelectedPageIndex = 0; } } } diff --git a/samples/ControlCatalog/NavHeaderItem.xaml b/samples/ControlCatalog/NavHeaderItem.xaml new file mode 100644 index 0000000000..6867661ebb --- /dev/null +++ b/samples/ControlCatalog/NavHeaderItem.xaml @@ -0,0 +1,101 @@ + + + + + + #99FFFFFF + #FF1F1F1F + #FF000000 + #FF171717 + + + #99000000 + #FFE6E6E6 + #FFFFFFFF + #FFF2F2F2 + + + 36 + 1 1 1 1 #2000, 0 0 1 1 #2fff + + + + Disabled + + Test + + Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/AcceleratorPage.xaml b/samples/ControlCatalog/Pages/AcceleratorPage.xaml index 18072ef1c3..62fcf0d746 100644 --- a/samples/ControlCatalog/Pages/AcceleratorPage.xaml +++ b/samples/ControlCatalog/Pages/AcceleratorPage.xaml @@ -1,115 +1,116 @@ - - + - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - + + - + - - Accelerator Support + + Accelerator Support - - - - This is tab 1 content - - This is tab 1 content - - This is tab 1 content - + + + + This is tab 1 content + + This is tab 1 content + + This is tab 1 content + - - - This is tab 2 content - - + + + This is tab 2 content + + - - - This is tab 4 content - - - This is fab 5 content - - - + + + This is tab 4 content + + + This is fab 5 content + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - + - - - - + + + + + - - + diff --git a/samples/ControlCatalog/Pages/AcceleratorPage.xaml.cs b/samples/ControlCatalog/Pages/AcceleratorPage.xaml.cs index e013d9aaac..40afacc053 100644 --- a/samples/ControlCatalog/Pages/AcceleratorPage.xaml.cs +++ b/samples/ControlCatalog/Pages/AcceleratorPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class AcceleratorPage : UserControl + public partial class AcceleratorPage : ContentPage { public AcceleratorPage() { diff --git a/samples/ControlCatalog/Pages/AcrylicPage.xaml b/samples/ControlCatalog/Pages/AcrylicPage.xaml index 4fd0933879..4a68fbfafd 100644 --- a/samples/ControlCatalog/Pages/AcrylicPage.xaml +++ b/samples/ControlCatalog/Pages/AcrylicPage.xaml @@ -1,12 +1,13 @@ - - + - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - + + + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + diff --git a/samples/ControlCatalog/Pages/AcrylicPage.xaml.cs b/samples/ControlCatalog/Pages/AcrylicPage.xaml.cs index 9516655bb9..adb5b05706 100644 --- a/samples/ControlCatalog/Pages/AcrylicPage.xaml.cs +++ b/samples/ControlCatalog/Pages/AcrylicPage.xaml.cs @@ -2,7 +2,7 @@ namespace ControlCatalog.Pages { - public partial class AcrylicPage : UserControl + public partial class AcrylicPage : ContentPage { public AcrylicPage() { diff --git a/samples/ControlCatalog/Pages/AdornerLayerPage.xaml b/samples/ControlCatalog/Pages/AdornerLayerPage.xaml index e9a245a8e1..35907c7ef8 100644 --- a/samples/ControlCatalog/Pages/AdornerLayerPage.xaml +++ b/samples/ControlCatalog/Pages/AdornerLayerPage.xaml @@ -1,52 +1,52 @@ - + + + Rotation + + - - - Rotation - - + + - + + + + + + + + + + + + + + - - - - + + + + diff --git a/samples/ControlCatalog/Pages/AdornerLayerPage.xaml.cs b/samples/ControlCatalog/Pages/AdornerLayerPage.xaml.cs index 526b8a492b..5ee8d44479 100644 --- a/samples/ControlCatalog/Pages/AdornerLayerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/AdornerLayerPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class AdornerLayerPage : UserControl + public partial class AdornerLayerPage : ContentPage { private Control? _adorner; diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml index 35e917f996..4edb00b7c3 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml @@ -1,79 +1,83 @@ - - - A control into which the user can input text + + + A control into which the user can input text - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs index 47b6eb7f4a..295aa9d139 100644 --- a/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs @@ -11,7 +11,7 @@ using ControlCatalog.Models; namespace ControlCatalog.Pages { - public partial class AutoCompleteBoxPage : UserControl + public partial class AutoCompleteBoxPage : ContentPage { private static StateData[] BuildAllStates() { diff --git a/samples/ControlCatalog/Pages/BitmapCachePage.axaml b/samples/ControlCatalog/Pages/BitmapCachePage.axaml index 5902be8e51..4298f29e8f 100644 --- a/samples/ControlCatalog/Pages/BitmapCachePage.axaml +++ b/samples/ControlCatalog/Pages/BitmapCachePage.axaml @@ -1,45 +1,49 @@ - + - - - - - - - Render at scale - - Scale - - Enable clear type + + + + + + + Render at scale + + Scale + + Enable clear type - Snap to device pixels - Subpixel offset X - - - - - - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - - - + Snap to device pixels + Subpixel offset X + + + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + - + + + - + + diff --git a/samples/ControlCatalog/Pages/BitmapCachePage.axaml.cs b/samples/ControlCatalog/Pages/BitmapCachePage.axaml.cs index 92b3cbec68..be7cf7a7ea 100644 --- a/samples/ControlCatalog/Pages/BitmapCachePage.axaml.cs +++ b/samples/ControlCatalog/Pages/BitmapCachePage.axaml.cs @@ -4,10 +4,10 @@ using Avalonia.Markup.Xaml; namespace ControlCatalog.Pages; -public partial class BitmapCachePage : UserControl +public partial class BitmapCachePage : ContentPage { public BitmapCachePage() { InitializeComponent(); } -} \ No newline at end of file +} diff --git a/samples/ControlCatalog/Pages/BorderPage.xaml b/samples/ControlCatalog/Pages/BorderPage.xaml index c811ddaa22..297e3fcfb8 100644 --- a/samples/ControlCatalog/Pages/BorderPage.xaml +++ b/samples/ControlCatalog/Pages/BorderPage.xaml @@ -1,61 +1,65 @@ - - - - - - A control which decorates a child with a border and background + + + + + + A control which decorates a child with a border and background - - - Border - - - Background And CenterBorder - - - Background And InnerBorderEdge - - - Background And OuterBorderEdge - - - Rounded Corners - - - Rounded Corners - - - - - + + + Border + + + Background And CenterBorder + + + Background And InnerBorderEdge + + + Background And OuterBorderEdge + + + Rounded Corners + + + Rounded Corners + + + + + + - - + + diff --git a/samples/ControlCatalog/Pages/BorderPage.xaml.cs b/samples/ControlCatalog/Pages/BorderPage.xaml.cs index 944df86f8c..71aebf24ff 100644 --- a/samples/ControlCatalog/Pages/BorderPage.xaml.cs +++ b/samples/ControlCatalog/Pages/BorderPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class BorderPage : UserControl + public partial class BorderPage : ContentPage { public BorderPage() { diff --git a/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml b/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml index 900e304559..c21a772c2a 100644 --- a/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml +++ b/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml @@ -1,6 +1,7 @@ - @@ -30,4 +31,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml.cs b/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml.cs index fad4b466fe..28f4b20084 100644 --- a/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ButtonSpinnerPage.xaml.cs @@ -3,7 +3,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class ButtonSpinnerPage : UserControl + public partial class ButtonSpinnerPage : ContentPage { public ButtonSpinnerPage() { diff --git a/samples/ControlCatalog/Pages/ButtonsPage.xaml b/samples/ControlCatalog/Pages/ButtonsPage.xaml index f13581aa18..695ae28515 100644 --- a/samples/ControlCatalog/Pages/ButtonsPage.xaml +++ b/samples/ControlCatalog/Pages/ButtonsPage.xaml @@ -1,8 +1,9 @@ - - + @@ -16,9 +17,9 @@ - + - + - + @@ -288,4 +289,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ButtonsPage.xaml.cs b/samples/ControlCatalog/Pages/ButtonsPage.xaml.cs index 6dcee1ab7d..611fc76241 100644 --- a/samples/ControlCatalog/Pages/ButtonsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ButtonsPage.xaml.cs @@ -3,7 +3,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class ButtonsPage : UserControl + public partial class ButtonsPage : ContentPage { private int repeatButtonClickCount = 0; diff --git a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml index 8734758d26..769dbc0dac 100644 --- a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml +++ b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml @@ -1,7 +1,8 @@ - A control for selecting dates with a calendar drop-down @@ -52,4 +53,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs index 73e1fe4bba..0e4fcbd986 100644 --- a/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CalendarDatePickerPage.xaml.cs @@ -3,7 +3,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class CalendarDatePickerPage : UserControl + public partial class CalendarDatePickerPage : ContentPage { public CalendarDatePickerPage() { diff --git a/samples/ControlCatalog/Pages/CalendarPage.xaml b/samples/ControlCatalog/Pages/CalendarPage.xaml index e142c4da72..99727e9124 100644 --- a/samples/ControlCatalog/Pages/CalendarPage.xaml +++ b/samples/ControlCatalog/Pages/CalendarPage.xaml @@ -1,5 +1,6 @@ - A calendar control for selecting dates @@ -49,4 +50,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CalendarPage.xaml.cs b/samples/ControlCatalog/Pages/CalendarPage.xaml.cs index 56f511be55..d9118326f9 100644 --- a/samples/ControlCatalog/Pages/CalendarPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CalendarPage.xaml.cs @@ -3,7 +3,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class CalendarPage : UserControl + public partial class CalendarPage : ContentPage { public CalendarPage() { diff --git a/samples/ControlCatalog/Pages/CanvasPage.xaml b/samples/ControlCatalog/Pages/CanvasPage.xaml index 416164f391..a9e342181d 100644 --- a/samples/ControlCatalog/Pages/CanvasPage.xaml +++ b/samples/ControlCatalog/Pages/CanvasPage.xaml @@ -1,5 +1,6 @@ - A panel which lays out its children by explicit coordinates @@ -34,4 +35,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CanvasPage.xaml.cs b/samples/ControlCatalog/Pages/CanvasPage.xaml.cs index e52df597a9..b94aabca94 100644 --- a/samples/ControlCatalog/Pages/CanvasPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CanvasPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class CanvasPage : UserControl + public partial class CanvasPage : ContentPage { public CanvasPage() { diff --git a/samples/ControlCatalog/Pages/CarouselDemoPage.xaml b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml index df4317fcad..792441ddb4 100644 --- a/samples/ControlCatalog/Pages/CarouselDemoPage.xaml +++ b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs index 36c9961658..0d59d296f6 100644 --- a/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CarouselDemoPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class CarouselDemoPage : UserControl + public partial class CarouselDemoPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/CarouselPage.xaml b/samples/ControlCatalog/Pages/CarouselPage.xaml index c6e20fec5b..bdb40b9038 100644 --- a/samples/ControlCatalog/Pages/CarouselPage.xaml +++ b/samples/ControlCatalog/Pages/CarouselPage.xaml @@ -1,5 +1,6 @@ - A swipeable items control that can reveal adjacent pages with ViewportFraction. @@ -115,4 +116,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CarouselPage.xaml.cs b/samples/ControlCatalog/Pages/CarouselPage.xaml.cs index 0a0c973b90..c4a6ffa12f 100644 --- a/samples/ControlCatalog/Pages/CarouselPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CarouselPage.xaml.cs @@ -7,7 +7,7 @@ using ControlCatalog.Pages.Transitions; namespace ControlCatalog.Pages { - public partial class CarouselPage : UserControl + public partial class CarouselPage : ContentPage { public CarouselPage() { diff --git a/samples/ControlCatalog/Pages/CheckBoxPage.xaml b/samples/ControlCatalog/Pages/CheckBoxPage.xaml index 2f60fc5dae..4f9c59448b 100644 --- a/samples/ControlCatalog/Pages/CheckBoxPage.xaml +++ b/samples/ControlCatalog/Pages/CheckBoxPage.xaml @@ -1,5 +1,6 @@ - A check box control @@ -25,4 +26,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CheckBoxPage.xaml.cs b/samples/ControlCatalog/Pages/CheckBoxPage.xaml.cs index 95ff21ef6d..b63d7084d6 100644 --- a/samples/ControlCatalog/Pages/CheckBoxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CheckBoxPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class CheckBoxPage : UserControl + public partial class CheckBoxPage : ContentPage { public CheckBoxPage() { diff --git a/samples/ControlCatalog/Pages/ClipboardPage.xaml b/samples/ControlCatalog/Pages/ClipboardPage.xaml index 864a520aca..86e99b9305 100644 --- a/samples/ControlCatalog/Pages/ClipboardPage.xaml +++ b/samples/ControlCatalog/Pages/ClipboardPage.xaml @@ -1,5 +1,6 @@ - Example of ClipboardPage capabilities @@ -27,4 +28,4 @@ /> - + diff --git a/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs b/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs index 65f58d0444..0bc5447313 100644 --- a/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ClipboardPage.xaml.cs @@ -15,7 +15,7 @@ using Avalonia.Threading; namespace ControlCatalog.Pages { - public partial class ClipboardPage : UserControl + public partial class ClipboardPage : ContentPage { private readonly DataFormat _customBinaryDataFormat = DataFormat.CreateBytesApplicationFormat("controlcatalog-binary-data"); diff --git a/samples/ControlCatalog/Pages/ColorPickerPage.xaml b/samples/ControlCatalog/Pages/ColorPickerPage.xaml index fb397085e7..f0b303e0d4 100644 --- a/samples/ControlCatalog/Pages/ColorPickerPage.xaml +++ b/samples/ControlCatalog/Pages/ColorPickerPage.xaml @@ -1,4 +1,4 @@ - - + - + - + diff --git a/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs b/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs index 4d2d236ed3..cc225b576d 100644 --- a/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ColorPickerPage.xaml.cs @@ -5,7 +5,7 @@ using Avalonia.Media; namespace ControlCatalog.Pages { - public partial class ColorPickerPage : UserControl + public partial class ColorPickerPage : ContentPage { public ColorPickerPage() { diff --git a/samples/ControlCatalog/Pages/ComboBoxPage.xaml b/samples/ControlCatalog/Pages/ComboBoxPage.xaml index 449c10f000..149fd73d0a 100644 --- a/samples/ControlCatalog/Pages/ComboBoxPage.xaml +++ b/samples/ControlCatalog/Pages/ComboBoxPage.xaml @@ -1,4 +1,4 @@ - - + diff --git a/samples/ControlCatalog/Pages/ComboBoxPage.xaml.cs b/samples/ControlCatalog/Pages/ComboBoxPage.xaml.cs index 301b052cb8..720aae9ef5 100644 --- a/samples/ControlCatalog/Pages/ComboBoxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ComboBoxPage.xaml.cs @@ -4,7 +4,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class ComboBoxPage : UserControl + public partial class ComboBoxPage : ContentPage { public ComboBoxPage() { diff --git a/samples/ControlCatalog/Pages/CommandBarPage.xaml b/samples/ControlCatalog/Pages/CommandBarPage.xaml index 6cf280ea95..3c648ea012 100644 --- a/samples/ControlCatalog/Pages/CommandBarPage.xaml +++ b/samples/ControlCatalog/Pages/CommandBarPage.xaml @@ -1,8 +1,11 @@ - - + - - - + + + + + diff --git a/samples/ControlCatalog/Pages/CommandBarPage.xaml.cs b/samples/ControlCatalog/Pages/CommandBarPage.xaml.cs index b759c7b605..0b81c698d2 100644 --- a/samples/ControlCatalog/Pages/CommandBarPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CommandBarPage.xaml.cs @@ -7,7 +7,7 @@ using Avalonia.Media; namespace ControlCatalog.Pages { - public partial class CommandBarPage : UserControl + public partial class CommandBarPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/CompositionPage.axaml b/samples/ControlCatalog/Pages/CompositionPage.axaml index 4d9bb41781..a3e9b047a8 100644 --- a/samples/ControlCatalog/Pages/CompositionPage.axaml +++ b/samples/ControlCatalog/Pages/CompositionPage.axaml @@ -1,62 +1,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - Resize me - - - + + + + + + + + + + + + + + + + + + + + + + + + + Resize me + + + + + + + + + + + + + + + + + + Precise dirty rects - - - - - - - - - - - - - - Precise dirty rects - - - - - - + + + + diff --git a/samples/ControlCatalog/Pages/CompositionPage.axaml.cs b/samples/ControlCatalog/Pages/CompositionPage.axaml.cs index 287bde0be8..8f5d75f4ce 100644 --- a/samples/ControlCatalog/Pages/CompositionPage.axaml.cs +++ b/samples/ControlCatalog/Pages/CompositionPage.axaml.cs @@ -15,7 +15,7 @@ using Math = System.Math; namespace ControlCatalog.Pages; -public partial class CompositionPage : UserControl +public partial class CompositionPage : TabbedPage { private ImplicitAnimationCollection? _implicitAnimations; private CompositionCustomVisual? _customVisual; diff --git a/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml b/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml index bf37b4cc4f..ca4a85af8d 100644 --- a/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml +++ b/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml @@ -1,6 +1,8 @@ - + - + + diff --git a/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml.cs b/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml.cs index 0c13bb360e..5d666730ae 100644 --- a/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ConnectedAnimationDemoPage.xaml.cs @@ -7,7 +7,7 @@ using Avalonia.Media; namespace ControlCatalog.Pages { - public partial class ConnectedAnimationDemoPage : UserControl + public partial class ConnectedAnimationDemoPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = []; diff --git a/samples/ControlCatalog/Pages/ContainerQueryPage.xaml b/samples/ControlCatalog/Pages/ContainerQueryPage.xaml index e6b0558a04..96f7a87586 100644 --- a/samples/ControlCatalog/Pages/ContainerQueryPage.xaml +++ b/samples/ControlCatalog/Pages/ContainerQueryPage.xaml @@ -1,9 +1,10 @@ - @@ -107,4 +108,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ContainerQueryPage.xaml.cs b/samples/ControlCatalog/Pages/ContainerQueryPage.xaml.cs index acd67c6629..b43723005e 100644 --- a/samples/ControlCatalog/Pages/ContainerQueryPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ContainerQueryPage.xaml.cs @@ -2,7 +2,7 @@ namespace ControlCatalog.Pages { - public partial class ContainerQueryPage : UserControl + public partial class ContainerQueryPage : ContentPage { public ContainerQueryPage() { diff --git a/samples/ControlCatalog/Pages/ContentDemoPage.xaml b/samples/ControlCatalog/Pages/ContentDemoPage.xaml index d8f2155a1b..bcf0ca67ef 100644 --- a/samples/ControlCatalog/Pages/ContentDemoPage.xaml +++ b/samples/ControlCatalog/Pages/ContentDemoPage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/ContentDemoPage.xaml.cs b/samples/ControlCatalog/Pages/ContentDemoPage.xaml.cs index e667cfc0ff..b47dde07c1 100644 --- a/samples/ControlCatalog/Pages/ContentDemoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ContentDemoPage.xaml.cs @@ -7,7 +7,7 @@ using Avalonia.Media; namespace ControlCatalog.Pages { - public partial class ContentDemoPage : UserControl + public partial class ContentDemoPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml b/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml index c23393e63c..fa52c05bfa 100644 --- a/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml +++ b/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml @@ -1,18 +1,19 @@ - - + - + @@ -156,4 +157,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml.cs b/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml.cs index bef2c8212d..f25b9341c3 100644 --- a/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ContextFlyoutPage.xaml.cs @@ -7,7 +7,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class ContextFlyoutPage : UserControl + public partial class ContextFlyoutPage : ContentPage { public ContextFlyoutPage() { diff --git a/samples/ControlCatalog/Pages/ContextMenuPage.xaml b/samples/ControlCatalog/Pages/ContextMenuPage.xaml index 0e7c7b9451..4d1d02aed8 100644 --- a/samples/ControlCatalog/Pages/ContextMenuPage.xaml +++ b/samples/ControlCatalog/Pages/ContextMenuPage.xaml @@ -1,7 +1,8 @@ - A right click menu that can be applied to any control. @@ -86,4 +87,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs b/samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs index a71398181c..86ce807127 100644 --- a/samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs @@ -6,7 +6,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class ContextMenuPage : UserControl + public partial class ContextMenuPage : ContentPage { public ContextMenuPage() { diff --git a/samples/ControlCatalog/Pages/CursorPage.xaml b/samples/ControlCatalog/Pages/CursorPage.xaml index 66f2b8b2e3..ae20193c97 100644 --- a/samples/ControlCatalog/Pages/CursorPage.xaml +++ b/samples/ControlCatalog/Pages/CursorPage.xaml @@ -1,6 +1,7 @@ - @@ -27,4 +28,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CursorPage.xaml.cs b/samples/ControlCatalog/Pages/CursorPage.xaml.cs index f9119175e2..88699ac6f2 100644 --- a/samples/ControlCatalog/Pages/CursorPage.xaml.cs +++ b/samples/ControlCatalog/Pages/CursorPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class CursorPage : UserControl + public partial class CursorPage : ContentPage { public CursorPage() { diff --git a/samples/ControlCatalog/Pages/CustomDrawing.xaml b/samples/ControlCatalog/Pages/CustomDrawing.xaml index 04b7fcfea5..f1cb2dab14 100644 --- a/samples/ControlCatalog/Pages/CustomDrawing.xaml +++ b/samples/ControlCatalog/Pages/CustomDrawing.xaml @@ -1,15 +1,16 @@ - - + - + @@ -104,4 +105,4 @@ - + diff --git a/samples/ControlCatalog/Pages/CustomDrawing.xaml.cs b/samples/ControlCatalog/Pages/CustomDrawing.xaml.cs index d3fedb76be..0eae942075 100644 --- a/samples/ControlCatalog/Pages/CustomDrawing.xaml.cs +++ b/samples/ControlCatalog/Pages/CustomDrawing.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class CustomDrawing : UserControl + public partial class CustomDrawing : ContentPage { public CustomDrawing() { diff --git a/samples/ControlCatalog/Pages/DataGridPage.xaml b/samples/ControlCatalog/Pages/DataGridPage.xaml index 3187e13f9f..04adf56700 100644 --- a/samples/ControlCatalog/Pages/DataGridPage.xaml +++ b/samples/ControlCatalog/Pages/DataGridPage.xaml @@ -1,5 +1,6 @@ - @@ -8,4 +9,4 @@ Click="OnLinkClicked" /> - + diff --git a/samples/ControlCatalog/Pages/DataGridPage.xaml.cs b/samples/ControlCatalog/Pages/DataGridPage.xaml.cs index 5fa4ec8b0e..1154506e2e 100644 --- a/samples/ControlCatalog/Pages/DataGridPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DataGridPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages; -public partial class DataGridPage : UserControl +public partial class DataGridPage : ContentPage { public DataGridPage() { diff --git a/samples/ControlCatalog/Pages/DataValidationPage.axaml b/samples/ControlCatalog/Pages/DataValidationPage.axaml index d46562addd..de4e398725 100644 --- a/samples/ControlCatalog/Pages/DataValidationPage.axaml +++ b/samples/ControlCatalog/Pages/DataValidationPage.axaml @@ -1,14 +1,15 @@ - - + - + - + diff --git a/samples/ControlCatalog/Pages/DataValidationPage.axaml.cs b/samples/ControlCatalog/Pages/DataValidationPage.axaml.cs index e38f85fec4..26bb75ca79 100644 --- a/samples/ControlCatalog/Pages/DataValidationPage.axaml.cs +++ b/samples/ControlCatalog/Pages/DataValidationPage.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; namespace ControlCatalog.Pages; -public partial class DataValidationPage : UserControl +public partial class DataValidationPage : ContentPage { public DataValidationPage() { diff --git a/samples/ControlCatalog/Pages/DateTimePickerPage.xaml b/samples/ControlCatalog/Pages/DateTimePickerPage.xaml index 7a1bfaa824..2183204c05 100644 --- a/samples/ControlCatalog/Pages/DateTimePickerPage.xaml +++ b/samples/ControlCatalog/Pages/DateTimePickerPage.xaml @@ -1,7 +1,8 @@ - @@ -207,4 +208,4 @@ - + diff --git a/samples/ControlCatalog/Pages/DateTimePickerPage.xaml.cs b/samples/ControlCatalog/Pages/DateTimePickerPage.xaml.cs index b5968a6b2a..99250d5fb0 100644 --- a/samples/ControlCatalog/Pages/DateTimePickerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DateTimePickerPage.xaml.cs @@ -2,7 +2,7 @@ namespace ControlCatalog.Pages { - public partial class DateTimePickerPage : UserControl + public partial class DateTimePickerPage : ContentPage { public DateTimePickerPage() { diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml b/samples/ControlCatalog/Pages/DialogsPage.xaml index e6b3568909..296b632b91 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml @@ -1,6 +1,7 @@ - - + diff --git a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs index adcf844552..616e3d4f62 100644 --- a/samples/ControlCatalog/Pages/DialogsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DialogsPage.xaml.cs @@ -12,7 +12,7 @@ using Avalonia.Platform.Storage; namespace ControlCatalog.Pages { - public partial class DialogsPage : UserControl + public partial class DialogsPage : ContentPage { public DialogsPage() { diff --git a/samples/ControlCatalog/Pages/DragAndDropPage.xaml b/samples/ControlCatalog/Pages/DragAndDropPage.xaml index 7982ddc1d0..2ca9ed27a0 100644 --- a/samples/ControlCatalog/Pages/DragAndDropPage.xaml +++ b/samples/ControlCatalog/Pages/DragAndDropPage.xaml @@ -1,15 +1,16 @@ - - + - + Example of Drag+Drop capabilities @@ -57,4 +58,4 @@ - + diff --git a/samples/ControlCatalog/Pages/DragAndDropPage.xaml.cs b/samples/ControlCatalog/Pages/DragAndDropPage.xaml.cs index fe2b306477..b2a91da381 100644 --- a/samples/ControlCatalog/Pages/DragAndDropPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DragAndDropPage.xaml.cs @@ -13,7 +13,7 @@ using Avalonia.Platform.Storage; namespace ControlCatalog.Pages { - public partial class DragAndDropPage : UserControl + public partial class DragAndDropPage : ContentPage { private readonly DataFormat _customFormat = DataFormat.CreateStringApplicationFormat("xxx-avalonia-controlcatalog-custom"); diff --git a/samples/ControlCatalog/Pages/DrawerDemoPage.xaml b/samples/ControlCatalog/Pages/DrawerDemoPage.xaml index 671a9a8487..f1edd0bc63 100644 --- a/samples/ControlCatalog/Pages/DrawerDemoPage.xaml +++ b/samples/ControlCatalog/Pages/DrawerDemoPage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/DrawerDemoPage.xaml.cs b/samples/ControlCatalog/Pages/DrawerDemoPage.xaml.cs index cd8aa9cd5b..27eb93ff03 100644 --- a/samples/ControlCatalog/Pages/DrawerDemoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/DrawerDemoPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class DrawerDemoPage : UserControl + public partial class DrawerDemoPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/ExpanderPage.xaml b/samples/ControlCatalog/Pages/ExpanderPage.xaml index b5a2e6cdd0..322da30a61 100644 --- a/samples/ControlCatalog/Pages/ExpanderPage.xaml +++ b/samples/ControlCatalog/Pages/ExpanderPage.xaml @@ -1,7 +1,8 @@ - Expands to show nested content @@ -72,4 +73,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ExpanderPage.xaml.cs b/samples/ControlCatalog/Pages/ExpanderPage.xaml.cs index 05c5cbee53..65b7b7e30b 100644 --- a/samples/ControlCatalog/Pages/ExpanderPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ExpanderPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class ExpanderPage : UserControl + public partial class ExpanderPage : ContentPage { public ExpanderPage() { diff --git a/samples/ControlCatalog/Pages/FlyoutsPage.axaml b/samples/ControlCatalog/Pages/FlyoutsPage.axaml index 64a005c987..840557bb9f 100644 --- a/samples/ControlCatalog/Pages/FlyoutsPage.axaml +++ b/samples/ControlCatalog/Pages/FlyoutsPage.axaml @@ -1,11 +1,12 @@ - - + @@ -25,7 +26,7 @@ - + @@ -282,4 +283,4 @@ - + diff --git a/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs b/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs index 91e92bc227..d6f54df074 100644 --- a/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs +++ b/samples/ControlCatalog/Pages/FlyoutsPage.axaml.cs @@ -7,7 +7,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class FlyoutsPage : UserControl + public partial class FlyoutsPage : ContentPage { public FlyoutsPage() { diff --git a/samples/ControlCatalog/Pages/FocusPage.xaml b/samples/ControlCatalog/Pages/FocusPage.xaml index f4bad7d138..6cb2647907 100644 --- a/samples/ControlCatalog/Pages/FocusPage.xaml +++ b/samples/ControlCatalog/Pages/FocusPage.xaml @@ -1,9 +1,10 @@ - @@ -47,4 +48,4 @@ - + diff --git a/samples/ControlCatalog/Pages/FocusPage.xaml.cs b/samples/ControlCatalog/Pages/FocusPage.xaml.cs index 2cc8067885..18aae471ab 100644 --- a/samples/ControlCatalog/Pages/FocusPage.xaml.cs +++ b/samples/ControlCatalog/Pages/FocusPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; namespace ControlCatalog.Pages; -public partial class FocusPage : UserControl +public partial class FocusPage : ContentPage { public FocusPage() { diff --git a/samples/ControlCatalog/Pages/GesturePage.xaml b/samples/ControlCatalog/Pages/GesturePage.xaml index bce18eab1d..da9ed5f807 100644 --- a/samples/ControlCatalog/Pages/GesturePage.xaml +++ b/samples/ControlCatalog/Pages/GesturePage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/GesturePage.cs b/samples/ControlCatalog/Pages/GesturePage.xaml.cs similarity index 96% rename from samples/ControlCatalog/Pages/GesturePage.cs rename to samples/ControlCatalog/Pages/GesturePage.xaml.cs index d8b89e0ecb..56c09573d0 100644 --- a/samples/ControlCatalog/Pages/GesturePage.cs +++ b/samples/ControlCatalog/Pages/GesturePage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class GesturePage : UserControl + public partial class GesturePage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/HeaderedContentPage.axaml b/samples/ControlCatalog/Pages/HeaderedContentPage.axaml index 86a2b00b72..cbf12695fd 100644 --- a/samples/ControlCatalog/Pages/HeaderedContentPage.axaml +++ b/samples/ControlCatalog/Pages/HeaderedContentPage.axaml @@ -1,8 +1,9 @@ - - + diff --git a/samples/ControlCatalog/Pages/HeaderedContentPage.axaml.cs b/samples/ControlCatalog/Pages/HeaderedContentPage.axaml.cs index ab967c4214..bfe033f90c 100644 --- a/samples/ControlCatalog/Pages/HeaderedContentPage.axaml.cs +++ b/samples/ControlCatalog/Pages/HeaderedContentPage.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; namespace ControlCatalog.Pages; -public partial class HeaderedContentPage : UserControl +public partial class HeaderedContentPage : ContentPage { public HeaderedContentPage() { diff --git a/samples/ControlCatalog/Pages/ImagePage.xaml b/samples/ControlCatalog/Pages/ImagePage.xaml index 444d370e42..abd9ff47b0 100644 --- a/samples/ControlCatalog/Pages/ImagePage.xaml +++ b/samples/ControlCatalog/Pages/ImagePage.xaml @@ -1,5 +1,6 @@ - @@ -65,4 +66,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ImagePage.xaml.cs b/samples/ControlCatalog/Pages/ImagePage.xaml.cs index f8630d7db6..eccdb9435f 100644 --- a/samples/ControlCatalog/Pages/ImagePage.xaml.cs +++ b/samples/ControlCatalog/Pages/ImagePage.xaml.cs @@ -5,7 +5,7 @@ using Avalonia.Media.Imaging; namespace ControlCatalog.Pages { - public partial class ImagePage : UserControl + public partial class ImagePage : ContentPage { public ImagePage() { diff --git a/samples/ControlCatalog/Pages/LabelsPage.axaml b/samples/ControlCatalog/Pages/LabelsPage.axaml index 5bfb2ee10e..cd367aa38a 100644 --- a/samples/ControlCatalog/Pages/LabelsPage.axaml +++ b/samples/ControlCatalog/Pages/LabelsPage.axaml @@ -1,13 +1,14 @@ - - + - + @@ -41,4 +42,4 @@ - + diff --git a/samples/ControlCatalog/Pages/LabelsPage.axaml.cs b/samples/ControlCatalog/Pages/LabelsPage.axaml.cs index f3a7647f8c..b26112b351 100644 --- a/samples/ControlCatalog/Pages/LabelsPage.axaml.cs +++ b/samples/ControlCatalog/Pages/LabelsPage.axaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.Models; namespace ControlCatalog.Pages { - public partial class LabelsPage : UserControl + public partial class LabelsPage : ContentPage { private Person? _person; diff --git a/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml b/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml index 8cf3610b47..d12bbfc302 100644 --- a/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml +++ b/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml @@ -1,5 +1,6 @@ - @@ -24,4 +25,4 @@ - + diff --git a/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml.cs b/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml.cs index 2060790594..e3815238be 100644 --- a/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml.cs +++ b/samples/ControlCatalog/Pages/LayoutTransformControlPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class LayoutTransformControlPage : UserControl + public partial class LayoutTransformControlPage : ContentPage { public LayoutTransformControlPage() { diff --git a/samples/ControlCatalog/Pages/ListBoxPage.xaml b/samples/ControlCatalog/Pages/ListBoxPage.xaml index e3a706bfed..f73a4c18ed 100644 --- a/samples/ControlCatalog/Pages/ListBoxPage.xaml +++ b/samples/ControlCatalog/Pages/ListBoxPage.xaml @@ -1,6 +1,7 @@ - @@ -47,4 +48,4 @@ SelectionMode="{Binding SelectionMode^}" WrapSelection="{Binding WrapSelection}"/> - + diff --git a/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs b/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs index 3dac437f3a..208b5cce4b 100644 --- a/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class ListBoxPage : UserControl + public partial class ListBoxPage : ContentPage { public ListBoxPage() { diff --git a/samples/ControlCatalog/Pages/MenuPage.xaml b/samples/ControlCatalog/Pages/MenuPage.xaml index bbcc759ca7..d9fb5d81bf 100644 --- a/samples/ControlCatalog/Pages/MenuPage.xaml +++ b/samples/ControlCatalog/Pages/MenuPage.xaml @@ -1,7 +1,8 @@ - Exported menu fallback @@ -95,4 +96,4 @@ - + diff --git a/samples/ControlCatalog/Pages/MenuPage.xaml.cs b/samples/ControlCatalog/Pages/MenuPage.xaml.cs index a07306b81d..56a229a594 100644 --- a/samples/ControlCatalog/Pages/MenuPage.xaml.cs +++ b/samples/ControlCatalog/Pages/MenuPage.xaml.cs @@ -4,7 +4,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class MenuPage : UserControl + public partial class MenuPage : ContentPage { public MenuPage() { diff --git a/samples/ControlCatalog/Pages/NativeEmbedPage.xaml b/samples/ControlCatalog/Pages/NativeEmbedPage.xaml index 89e636112c..71d622bae4 100644 --- a/samples/ControlCatalog/Pages/NativeEmbedPage.xaml +++ b/samples/ControlCatalog/Pages/NativeEmbedPage.xaml @@ -1,10 +1,11 @@ - @@ -65,4 +66,4 @@ - + diff --git a/samples/ControlCatalog/Pages/NativeEmbedPage.xaml.cs b/samples/ControlCatalog/Pages/NativeEmbedPage.xaml.cs index b9bac10f9a..1cd1f78cc0 100644 --- a/samples/ControlCatalog/Pages/NativeEmbedPage.xaml.cs +++ b/samples/ControlCatalog/Pages/NativeEmbedPage.xaml.cs @@ -7,7 +7,7 @@ using Avalonia.Platform; namespace ControlCatalog.Pages { - public partial class NativeEmbedPage : UserControl + public partial class NativeEmbedPage : ContentPage { public NativeEmbedPage() { diff --git a/samples/ControlCatalog/Pages/NavigationDemoPage.xaml b/samples/ControlCatalog/Pages/NavigationDemoPage.xaml index 4849b2d5b8..0f7536b6a3 100644 --- a/samples/ControlCatalog/Pages/NavigationDemoPage.xaml +++ b/samples/ControlCatalog/Pages/NavigationDemoPage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/NavigationDemoPage.xaml.cs b/samples/ControlCatalog/Pages/NavigationDemoPage.xaml.cs index d65a43a6ad..7ca41ab893 100644 --- a/samples/ControlCatalog/Pages/NavigationDemoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/NavigationDemoPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class NavigationDemoPage : UserControl + public partial class NavigationDemoPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/NotificationsPage.xaml b/samples/ControlCatalog/Pages/NotificationsPage.xaml index b4094d8a2e..2ae1db7d43 100644 --- a/samples/ControlCatalog/Pages/NotificationsPage.xaml +++ b/samples/ControlCatalog/Pages/NotificationsPage.xaml @@ -1,8 +1,9 @@ - - + diff --git a/samples/ControlCatalog/Pages/NotificationsPage.xaml.cs b/samples/ControlCatalog/Pages/NotificationsPage.xaml.cs index f3db564571..5ff67e10dc 100644 --- a/samples/ControlCatalog/Pages/NotificationsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/NotificationsPage.xaml.cs @@ -5,7 +5,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class NotificationsPage : UserControl + public partial class NotificationsPage : ContentPage { private NotificationViewModel _viewModel; diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml index a112f79c02..dcc84c3ae8 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml @@ -1,8 +1,9 @@ - - + diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs index 379090830d..db64fba0ef 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml.cs @@ -9,7 +9,7 @@ using MiniMvvm; namespace ControlCatalog.Pages { - public partial class NumericUpDownPage : UserControl + public partial class NumericUpDownPage : ContentPage { public NumericUpDownPage() { diff --git a/samples/ControlCatalog/Pages/OpenGlPage.xaml b/samples/ControlCatalog/Pages/OpenGlPage.xaml index 0e557cc1ad..9119be05f5 100644 --- a/samples/ControlCatalog/Pages/OpenGlPage.xaml +++ b/samples/ControlCatalog/Pages/OpenGlPage.xaml @@ -1,7 +1,8 @@ - @@ -10,4 +11,4 @@ IsVisible="False" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="SnapshotClick">Snapshot - + diff --git a/samples/ControlCatalog/Pages/OpenGlPage.xaml.cs b/samples/ControlCatalog/Pages/OpenGlPage.xaml.cs index 09173e01a5..51dc4c2c72 100644 --- a/samples/ControlCatalog/Pages/OpenGlPage.xaml.cs +++ b/samples/ControlCatalog/Pages/OpenGlPage.xaml.cs @@ -11,7 +11,7 @@ using ControlCatalog.Pages.OpenGl; namespace ControlCatalog.Pages { - public partial class OpenGlPage : UserControl + public partial class OpenGlPage : ContentPage { public OpenGlPage() { diff --git a/samples/ControlCatalog/Pages/PipsPagerPage.xaml b/samples/ControlCatalog/Pages/PipsPagerPage.xaml index 54112daae0..aee21a7d01 100644 --- a/samples/ControlCatalog/Pages/PipsPagerPage.xaml +++ b/samples/ControlCatalog/Pages/PipsPagerPage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/PipsPagerPage.xaml.cs b/samples/ControlCatalog/Pages/PipsPagerPage.xaml.cs index 0559a265e4..5a3b142f59 100644 --- a/samples/ControlCatalog/Pages/PipsPagerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/PipsPagerPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class PipsPagerPage : UserControl + public partial class PipsPagerPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/PlatformInfoPage.xaml b/samples/ControlCatalog/Pages/PlatformInfoPage.xaml index 22c47f6bef..f86d53b740 100644 --- a/samples/ControlCatalog/Pages/PlatformInfoPage.xaml +++ b/samples/ControlCatalog/Pages/PlatformInfoPage.xaml @@ -1,4 +1,4 @@ - @@ -53,4 +54,4 @@ - + diff --git a/samples/ControlCatalog/Pages/PlatformInfoPage.xaml.cs b/samples/ControlCatalog/Pages/PlatformInfoPage.xaml.cs index 5066bc51de..db1bbef40c 100644 --- a/samples/ControlCatalog/Pages/PlatformInfoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/PlatformInfoPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class PlatformInfoPage : UserControl + public partial class PlatformInfoPage : ContentPage { public PlatformInfoPage() { diff --git a/samples/ControlCatalog/Pages/PointersPage.xaml b/samples/ControlCatalog/Pages/PointersPage.xaml index dda85316f6..2f958b901b 100644 --- a/samples/ControlCatalog/Pages/PointersPage.xaml +++ b/samples/ControlCatalog/Pages/PointersPage.xaml @@ -1,12 +1,12 @@ - - - + - - + + - - + + - - + + Capture 2 - - - + + diff --git a/samples/ControlCatalog/Pages/PointersPage.xaml.cs b/samples/ControlCatalog/Pages/PointersPage.xaml.cs index adf45029ec..388c8fa382 100644 --- a/samples/ControlCatalog/Pages/PointersPage.xaml.cs +++ b/samples/ControlCatalog/Pages/PointersPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Input; namespace ControlCatalog.Pages; -public partial class PointersPage : UserControl +public partial class PointersPage : TabbedPage { public PointersPage() { diff --git a/samples/ControlCatalog/Pages/ProgressBarPage.xaml b/samples/ControlCatalog/Pages/ProgressBarPage.xaml index 52e1e198b5..3b80b5a6bb 100644 --- a/samples/ControlCatalog/Pages/ProgressBarPage.xaml +++ b/samples/ControlCatalog/Pages/ProgressBarPage.xaml @@ -1,4 +1,8 @@ - + A progress bar control @@ -18,10 +22,10 @@ - - @@ -36,4 +40,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ProgressBarPage.xaml.cs b/samples/ControlCatalog/Pages/ProgressBarPage.xaml.cs index 42b9fe29d7..244161a61e 100644 --- a/samples/ControlCatalog/Pages/ProgressBarPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ProgressBarPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class ProgressBarPage : UserControl + public partial class ProgressBarPage : ContentPage { public ProgressBarPage() { diff --git a/samples/ControlCatalog/Pages/RadioButtonPage.xaml b/samples/ControlCatalog/Pages/RadioButtonPage.xaml index 8623d81b3f..efb63ea124 100644 --- a/samples/ControlCatalog/Pages/RadioButtonPage.xaml +++ b/samples/ControlCatalog/Pages/RadioButtonPage.xaml @@ -1,5 +1,6 @@ - Allows the selection of a single option of many @@ -37,4 +38,4 @@ - + diff --git a/samples/ControlCatalog/Pages/RadioButtonPage.xaml.cs b/samples/ControlCatalog/Pages/RadioButtonPage.xaml.cs index 798df9fe77..8199a7caf5 100644 --- a/samples/ControlCatalog/Pages/RadioButtonPage.xaml.cs +++ b/samples/ControlCatalog/Pages/RadioButtonPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class RadioButtonPage : UserControl + public partial class RadioButtonPage : ContentPage { public RadioButtonPage() { diff --git a/samples/ControlCatalog/Pages/RefreshContainerPage.axaml b/samples/ControlCatalog/Pages/RefreshContainerPage.axaml index f6ea26a84c..06f54dd28a 100644 --- a/samples/ControlCatalog/Pages/RefreshContainerPage.axaml +++ b/samples/ControlCatalog/Pages/RefreshContainerPage.axaml @@ -1,4 +1,4 @@ - - + diff --git a/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs b/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs index a710cd7e5c..2c886fa9de 100644 --- a/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs +++ b/samples/ControlCatalog/Pages/RefreshContainerPage.axaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class RefreshContainerPage : UserControl + public partial class RefreshContainerPage : ContentPage { private RefreshContainerViewModel _viewModel; diff --git a/samples/ControlCatalog/Pages/RelativePanelPage.axaml b/samples/ControlCatalog/Pages/RelativePanelPage.axaml index a6647b0d36..ccc39befd4 100644 --- a/samples/ControlCatalog/Pages/RelativePanelPage.axaml +++ b/samples/ControlCatalog/Pages/RelativePanelPage.axaml @@ -1,8 +1,9 @@ - @@ -60,4 +61,4 @@ - + diff --git a/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs b/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs index aec13a18e3..3c59deb791 100644 --- a/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs +++ b/samples/ControlCatalog/Pages/RelativePanelPage.axaml.cs @@ -2,7 +2,7 @@ namespace ControlCatalog.Pages { - public partial class RelativePanelPage : UserControl + public partial class RelativePanelPage : ContentPage { public RelativePanelPage() { diff --git a/samples/ControlCatalog/Pages/ScreenPage.cs b/samples/ControlCatalog/Pages/ScreenPage.cs index 66e90c2b34..9791152923 100644 --- a/samples/ControlCatalog/Pages/ScreenPage.cs +++ b/samples/ControlCatalog/Pages/ScreenPage.cs @@ -11,7 +11,7 @@ using Avalonia.Threading; namespace ControlCatalog.Pages { - public class ScreenPage : UserControl + public class ScreenPage : ContentPage { private double _leftMost; private double _topMost; diff --git a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml index f931542a04..0567dbe451 100644 --- a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml +++ b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml @@ -1,10 +1,10 @@ - - - + - - + + - - - + + diff --git a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs index 7c684357d3..cfdd5bab54 100644 --- a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs @@ -92,7 +92,7 @@ namespace ControlCatalog.Pages public List AvailableSnapPointsAlignment { get; } } - public partial class ScrollViewerPage : UserControl + public partial class ScrollViewerPage : TabbedPage { public ScrollViewerPage() { diff --git a/samples/ControlCatalog/Pages/SliderPage.xaml b/samples/ControlCatalog/Pages/SliderPage.xaml index 7821e885ba..445564cb54 100644 --- a/samples/ControlCatalog/Pages/SliderPage.xaml +++ b/samples/ControlCatalog/Pages/SliderPage.xaml @@ -1,5 +1,6 @@ - @@ -80,4 +81,4 @@ - + diff --git a/samples/ControlCatalog/Pages/SliderPage.xaml.cs b/samples/ControlCatalog/Pages/SliderPage.xaml.cs index 8345df8716..f65f714300 100644 --- a/samples/ControlCatalog/Pages/SliderPage.xaml.cs +++ b/samples/ControlCatalog/Pages/SliderPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class SliderPage : UserControl + public partial class SliderPage : ContentPage { public SliderPage() { diff --git a/samples/ControlCatalog/Pages/SplitViewPage.xaml b/samples/ControlCatalog/Pages/SplitViewPage.xaml index 201765ad88..144688e358 100644 --- a/samples/ControlCatalog/Pages/SplitViewPage.xaml +++ b/samples/ControlCatalog/Pages/SplitViewPage.xaml @@ -1,8 +1,9 @@ - @@ -109,4 +110,4 @@ - + diff --git a/samples/ControlCatalog/Pages/SplitViewPage.xaml.cs b/samples/ControlCatalog/Pages/SplitViewPage.xaml.cs index b711db3c49..4917a13ccf 100644 --- a/samples/ControlCatalog/Pages/SplitViewPage.xaml.cs +++ b/samples/ControlCatalog/Pages/SplitViewPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class SplitViewPage : UserControl + public partial class SplitViewPage : ContentPage { public SplitViewPage() { diff --git a/samples/ControlCatalog/Pages/TabControlPage.xaml b/samples/ControlCatalog/Pages/TabControlPage.xaml index a3bacfd92a..e7aa18ea84 100644 --- a/samples/ControlCatalog/Pages/TabControlPage.xaml +++ b/samples/ControlCatalog/Pages/TabControlPage.xaml @@ -1,7 +1,8 @@ - @@ -108,4 +109,4 @@ - + diff --git a/samples/ControlCatalog/Pages/TabControlPage.xaml.cs b/samples/ControlCatalog/Pages/TabControlPage.xaml.cs index b7f34eda86..366b5216ef 100644 --- a/samples/ControlCatalog/Pages/TabControlPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TabControlPage.xaml.cs @@ -6,7 +6,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class TabControlPage : UserControl + public partial class TabControlPage : ContentPage { public TabControlPage() { diff --git a/samples/ControlCatalog/Pages/TabStripPage.xaml b/samples/ControlCatalog/Pages/TabStripPage.xaml index b576beeb5f..f4a47af353 100644 --- a/samples/ControlCatalog/Pages/TabStripPage.xaml +++ b/samples/ControlCatalog/Pages/TabStripPage.xaml @@ -1,6 +1,7 @@ - @@ -31,4 +32,4 @@ - + diff --git a/samples/ControlCatalog/Pages/TabStripPage.xaml.cs b/samples/ControlCatalog/Pages/TabStripPage.xaml.cs index d2873f6586..d830109833 100644 --- a/samples/ControlCatalog/Pages/TabStripPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TabStripPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class TabStripPage : UserControl + public partial class TabStripPage : ContentPage { public TabStripPage() { diff --git a/samples/ControlCatalog/Pages/TabbedDemoPage.xaml b/samples/ControlCatalog/Pages/TabbedDemoPage.xaml index bb1467060b..58a3b4fe82 100644 --- a/samples/ControlCatalog/Pages/TabbedDemoPage.xaml +++ b/samples/ControlCatalog/Pages/TabbedDemoPage.xaml @@ -1,11 +1,14 @@ - - - - - - - + + + + + + + + diff --git a/samples/ControlCatalog/Pages/TabbedDemoPage.xaml.cs b/samples/ControlCatalog/Pages/TabbedDemoPage.xaml.cs index 51da6330a1..88692c97f3 100644 --- a/samples/ControlCatalog/Pages/TabbedDemoPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TabbedDemoPage.xaml.cs @@ -4,7 +4,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class TabbedDemoPage : UserControl + public partial class TabbedDemoPage : ContentPage { private static readonly (string Group, string Title, string Description, Func Factory)[] Demos = { diff --git a/samples/ControlCatalog/Pages/TextBlockPage.xaml b/samples/ControlCatalog/Pages/TextBlockPage.xaml index 7c0300d318..3418cffe74 100644 --- a/samples/ControlCatalog/Pages/TextBlockPage.xaml +++ b/samples/ControlCatalog/Pages/TextBlockPage.xaml @@ -1,5 +1,6 @@ - A control that can display text @@ -137,4 +138,4 @@ - + diff --git a/samples/ControlCatalog/Pages/TextBlockPage.xaml.cs b/samples/ControlCatalog/Pages/TextBlockPage.xaml.cs index d097d1d083..d10d255a4f 100644 --- a/samples/ControlCatalog/Pages/TextBlockPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TextBlockPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class TextBlockPage : UserControl + public partial class TextBlockPage : ContentPage { public TextBlockPage() { diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 346e561dfc..9b5a412f86 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -1,6 +1,7 @@ - @@ -101,4 +102,4 @@ FontFamily="avares://ControlCatalog/Assets/Fonts#WenQuanYi Micro Hei" Text="计算机科学(是系统性研究信息与计算的理论基础以及它们在计算机系统中如何实现与应用的实用技术的学科。它通常被形容为对那些创造、描述以及转换信息的算法处理的系统研究。计算机科学包含很多分支领域;有些强调特定结果的计算,比如计算机图形学;而有些是探討计算问题的性质,比如计算复杂性理论;还有一些领域專注于怎样实现计算,比如程式語言理論是研究描述计算的方法,而程式设计是应用特定的程式語言解决特定的计算问题,人机交互则是專注于怎样使计算机和计算变得有用、好用,以及随时随地为人所用。 有时公众会误以为计算机科学就是解决计算机问题的事业(比如信息技术),或者只是与使用计算机的经验有关,如玩游戏、上网或者文字处理。其实计算机科学所关注的,不仅仅是去理解实现类似游戏、浏览器这些软件的程序的性质,更要通过现有的知识创造新的程序或者改进已有的程序。" /> - + diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml.cs b/samples/ControlCatalog/Pages/TextBoxPage.xaml.cs index 035f951a6b..3c38a05c53 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class TextBoxPage : UserControl + public partial class TextBoxPage : ContentPage { public TextBoxPage() { diff --git a/samples/ControlCatalog/Pages/ThemePage.axaml b/samples/ControlCatalog/Pages/ThemePage.axaml index 7eb95471a0..ccc5769fe7 100644 --- a/samples/ControlCatalog/Pages/ThemePage.axaml +++ b/samples/ControlCatalog/Pages/ThemePage.axaml @@ -1,13 +1,14 @@ - - + @@ -52,7 +53,7 @@ - + - + diff --git a/samples/ControlCatalog/Pages/ThemePage.axaml.cs b/samples/ControlCatalog/Pages/ThemePage.axaml.cs index d355b399a4..4f45e93ed0 100644 --- a/samples/ControlCatalog/Pages/ThemePage.axaml.cs +++ b/samples/ControlCatalog/Pages/ThemePage.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Styling; namespace ControlCatalog.Pages { - public partial class ThemePage : UserControl + public partial class ThemePage : ContentPage { public static ThemeVariant Pink { get; } = new("Pink", ThemeVariant.Light); diff --git a/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml index 6afe6dd135..126cc7e7d2 100644 --- a/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml +++ b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml @@ -1,5 +1,6 @@ - @@ -17,7 +18,7 @@ + Text="<ToggleSwitch>headered</ToggleSwitch>"/> @@ -26,14 +27,14 @@ + OnContent="On" + OffContent="Off" + Margin="10"/> - + @@ -55,7 +56,7 @@ ContentOff="Off" />" - + - - + + diff --git a/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs index 77d77daeed..a60eb295b0 100644 --- a/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs @@ -2,7 +2,7 @@ namespace ControlCatalog.Pages { - public partial class ToggleSwitchPage : UserControl + public partial class ToggleSwitchPage : ContentPage { public ToggleSwitchPage() { diff --git a/samples/ControlCatalog/Pages/ToolTipPage.xaml b/samples/ControlCatalog/Pages/ToolTipPage.xaml index 8b76cccbc9..cc3a50b8e9 100644 --- a/samples/ControlCatalog/Pages/ToolTipPage.xaml +++ b/samples/ControlCatalog/Pages/ToolTipPage.xaml @@ -1,5 +1,6 @@ - @@ -10,7 +11,7 @@ HorizontalAlignment="Center"> - + diff --git a/samples/ControlCatalog/Pages/ToolTipPage.xaml.cs b/samples/ControlCatalog/Pages/ToolTipPage.xaml.cs index cd0b5c72a8..e436407dc5 100644 --- a/samples/ControlCatalog/Pages/ToolTipPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ToolTipPage.xaml.cs @@ -6,7 +6,7 @@ using Avalonia.Interactivity; namespace ControlCatalog.Pages { - public partial class ToolTipPage : UserControl + public partial class ToolTipPage : ContentPage { public ToolTipPage() { diff --git a/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml b/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml index 03ef86fb61..5435ed278d 100644 --- a/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml +++ b/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml @@ -1,19 +1,20 @@ - - + - + - + - + - + 8 - + @@ -81,4 +82,4 @@ - + diff --git a/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml.cs b/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml.cs index 863ddae6e0..818ab6219d 100644 --- a/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml.cs +++ b/samples/ControlCatalog/Pages/TransitioningContentControlPage.axaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class TransitioningContentControlPage : UserControl + public partial class TransitioningContentControlPage : ContentPage { public TransitioningContentControlPage() { diff --git a/samples/ControlCatalog/Pages/TreeViewPage.xaml b/samples/ControlCatalog/Pages/TreeViewPage.xaml index 2e3fca58cb..88dc65b5f2 100644 --- a/samples/ControlCatalog/Pages/TreeViewPage.xaml +++ b/samples/ControlCatalog/Pages/TreeViewPage.xaml @@ -1,6 +1,7 @@ - @@ -32,4 +33,4 @@ - + diff --git a/samples/ControlCatalog/Pages/TreeViewPage.xaml.cs b/samples/ControlCatalog/Pages/TreeViewPage.xaml.cs index c43c2eb49e..d03590febd 100644 --- a/samples/ControlCatalog/Pages/TreeViewPage.xaml.cs +++ b/samples/ControlCatalog/Pages/TreeViewPage.xaml.cs @@ -3,7 +3,7 @@ using ControlCatalog.ViewModels; namespace ControlCatalog.Pages { - public partial class TreeViewPage : UserControl + public partial class TreeViewPage : ContentPage { public TreeViewPage() { diff --git a/samples/ControlCatalog/Pages/ViewboxPage.xaml b/samples/ControlCatalog/Pages/ViewboxPage.xaml index e66655253c..3848e405db 100644 --- a/samples/ControlCatalog/Pages/ViewboxPage.xaml +++ b/samples/ControlCatalog/Pages/ViewboxPage.xaml @@ -1,6 +1,7 @@ - @@ -50,4 +51,4 @@ - + diff --git a/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs b/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs index c140cb9857..f7b1ea3f75 100644 --- a/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ViewboxPage.xaml.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; namespace ControlCatalog.Pages { - public partial class ViewboxPage : UserControl + public partial class ViewboxPage : ContentPage { public ViewboxPage() { diff --git a/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml b/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml index df84c0bd6b..0017ee09b5 100644 --- a/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml +++ b/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml @@ -1,9 +1,10 @@ - @@ -50,4 +51,4 @@ - + diff --git a/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml.cs b/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml.cs index d62c7ec10f..2ee8677eba 100644 --- a/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml.cs +++ b/samples/ControlCatalog/Pages/WindowCustomizationsPage.xaml.cs @@ -2,7 +2,7 @@ namespace ControlCatalog.Pages { - public partial class WindowCustomizationsPage : UserControl + public partial class WindowCustomizationsPage : ContentPage { public WindowCustomizationsPage() { diff --git a/samples/ControlCatalog/ScrollPage.xaml b/samples/ControlCatalog/ScrollPage.xaml new file mode 100644 index 0000000000..6d5ecb815e --- /dev/null +++ b/samples/ControlCatalog/ScrollPage.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs index ce9209f61a..0d877b253f 100644 --- a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs +++ b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs @@ -8,7 +8,7 @@ using MiniMvvm; namespace ControlCatalog.ViewModels { - class MainWindowViewModel : ViewModelBase + partial class MainWindowViewModel : ViewModelBase { private WindowState _windowState; private WindowState[] _windowStates = Array.Empty(); @@ -20,6 +20,7 @@ namespace ControlCatalog.ViewModels private bool _canResize; private bool _canMinimize; private bool _canMaximize; + private int _selectedDecorationIndex; public MainWindowViewModel() { @@ -51,6 +52,8 @@ namespace ControlCatalog.ViewModels CanResize = true; CanMinimize = true; CanMaximize = true; + + Filter(); } public bool ExtendClientAreaEnabled @@ -113,6 +116,12 @@ namespace ControlCatalog.ViewModels set { RaiseAndSetIfChanged(ref _canMaximize, value); } } + public int SelectedDecorationIndex + { + get { return _selectedDecorationIndex; } + set { RaiseAndSetIfChanged(ref _selectedDecorationIndex, value); } + } + public MiniCommand AboutCommand { get; } diff --git a/samples/ControlCatalog/ViewModels/MainWindowViewModel_PageList.cs b/samples/ControlCatalog/ViewModels/MainWindowViewModel_PageList.cs new file mode 100644 index 0000000000..4c85f64765 --- /dev/null +++ b/samples/ControlCatalog/ViewModels/MainWindowViewModel_PageList.cs @@ -0,0 +1,196 @@ +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using Avalonia.Dialogs; +using System; +using System.ComponentModel.DataAnnotations; +using Avalonia; +using MiniMvvm; +using Avalonia.Collections; +using ControlCatalog.Pages; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; + +namespace ControlCatalog.ViewModels +{ + partial class MainWindowViewModel + { + private int _selectedPageIndex; + private bool _isDrawerOpened = true; + private bool _ignoreListChange = false; + private string? _query = ""; + private PageItem? _currentItem; + private SplitViewDisplayMode _displayMode; + + private List _items = new() + { + new PageItem("Composition", () => new CompositionPage(), Icons.Layers), + new PageItem("Accelerator", () => new AcceleratorPage(), Icons.Keyboard), + new PageItem("Acrylic", () => new AcrylicPage(), Icons.Blur), + new PageItem("AdornerLayer", () => new AdornerLayerPage(), Icons.Sparkle), + new PageItem("AutoCompleteBox",() => new AutoCompleteBoxPage(), Icons.TextInput), + new PageItem("Border",() => new BorderPage(), Icons.Border), + new PageItem("BitmapCache",() => new BitmapCachePage(), Icons.Lightning), + new PageItem("Buttons",() => new ButtonsPage(), Icons.CursorClick), + new PageItem("ButtonSpinner",() => new ButtonSpinnerPage(), Icons.Spinner), + new PageItem("Calendar",() => new CalendarPage(), Icons.Calendar), + new PageItem("Canvas",() => new CanvasPage(), Icons.Canvas), + new PageItem("CommandBar",() => new CommandBarPage(), Icons.Terminal), + new PageItem("Carousel",() => new Pages.CarouselPage(), Icons.Slides), + new PageItem("CarouselPage",() => new CarouselDemoPage(), Icons.Slides), + new PageItem("CheckBox",() => new CheckBoxPage(), Icons.Checkbox), + new PageItem("Clipboard",() => new ClipboardPage(), Icons.Clipboard), + new PageItem("ColorPicker",() => new ColorPickerPage(), Icons.Palette), + new PageItem("ComboBox",() => new ComboBoxPage(), Icons.Dropdown), + new PageItem("Container Queries",() => new ContainerQueryPage(), Icons.Container), + new PageItem("ContentPage",() => new ContentDemoPage(), Icons.Document), + new PageItem("ContextFlyout",() => new ContextFlyoutPage(), Icons.Menu), + new PageItem("ContextMenu",() => new ContextMenuPage(), Icons.Menu), + new PageItem("Cursor",() => new CursorPage(), Icons.Cursor), + new PageItem("Custom Drawing",() => new CustomDrawing(), Icons.Brush), + new PageItem("DataGrid",() => new DataGridPage(), Icons.Grid), + new PageItem("Data Validation",() => new DataValidationPage(), Icons.Shield), + new PageItem("Date/Time Picker",() => new DateTimePickerPage(), Icons.Clock), + new PageItem("CalendarDatePicker",() => new CalendarDatePickerPage(), Icons.Calendar), + new PageItem("Dialogs",() => new DialogsPage(), Icons.Dialog), + new PageItem("Drag+Drop",() => new DragAndDropPage(), Icons.DragDrop), + new PageItem("DrawerPage",() => new DrawerDemoPage(), Icons.Drawer), + new PageItem("Expander",() => new ExpanderPage(), Icons.Expand), + new PageItem("Flyouts",() => new FlyoutsPage(), Icons.Flyout), + new PageItem("Focus",() => new FocusPage(), Icons.Target), + new PageItem("Gestures",() => new GesturePage(), Icons.Gesture), + new PageItem("Image",() => new ImagePage(), Icons.Image), + new PageItem("Label",() => new LabelsPage(), Icons.Tag), + new PageItem("LayoutTransformControl",() => new LayoutTransformControlPage(), Icons.Transform), + new PageItem("ListBox",() => new ListBoxPage(), Icons.List), + new PageItem("Menu",() => new MenuPage(), Icons.Menu), + new PageItem("NavigationPage",() => new NavigationDemoPage(), Icons.Navigation), + new PageItem("Notifications",() => new NotificationsPage(), Icons.Bell), + new PageItem("NumericUpDown",() => new NumericUpDownPage(), Icons.Number), + new PageItem("OpenGL",() => new OpenGlPage(), Icons.Cube3D), + new PageItem("OpenGL Lease",() => new OpenGlLeasePage(), Icons.Cube3D), + new PageItem("PipsPager",() => new PipsPagerPage(), Icons.HorizontalDots), + new PageItem("Platform Information",() => new PlatformInfoPage(), Icons.Info), + new PageItem("Pointers",() => new PointersPage(), Icons.Cursor), + new PageItem("ProgressBar",() => new ProgressBarPage(), Icons.Progress), + new PageItem("RadioButton",() => new RadioButtonPage(), Icons.Radio), + new PageItem("RefreshContainer",() => new RefreshContainerPage(), Icons.Refresh), + new PageItem("RelativePanel",() => new RelativePanelPage(), Icons.Layout), + new PageItem("ScrollViewer",() => new ScrollViewerPage(), Icons.Scroll), + new PageItem("Slider",() => new SliderPage(), Icons.Tune), + new PageItem("SplitView",() => new SplitViewPage(), Icons.Split), + new PageItem("TabbedPage",() => new TabbedDemoPage(), Icons.Tab), + new PageItem("TabControl",() => new TabControlPage(), Icons.Tab), + new PageItem("TabStrip",() => new TabStripPage(), Icons.Tab), + new PageItem("TextBox",() => new TextBoxPage(), Icons.TextInput), + new PageItem("TextBlock",() => new TextBlockPage(), Icons.TextInput), + new PageItem("Theme Variants",() => new ThemePage(), Icons.Theme), + new PageItem("ToggleSwitch",() => new ToggleSwitchPage(), Icons.Toggle), + new PageItem("ToolTip",() => new ToolTipPage(), Icons.Tooltip), + new PageItem("TransitioningContentControl",() => new TransitioningContentControlPage(), Icons.Transition), + new PageItem("TreeView",() => new TreeViewPage(), Icons.Tree), + new PageItem("Viewbox",() => new ViewboxPage(), Icons.Viewbox), + new PageItem("Native Embed",() => new NativeEmbedPage(), Icons.Puzzle), + new PageItem("Window Customizations",() => new WindowCustomizationsPage(), Icons.Window), + new PageItem("HeaderedContentControl",() => new HeaderedContentPage(), Icons.Header), + new PageItem("Screens",() => new ScreenPage(), Icons.Monitor), + }; + + public AvaloniaList Pages { get; } = new AvaloniaList(); + + public void Filter(string? query = "") + { + try + { + _ignoreListChange = true; + Pages.Clear(); + + if (!string.IsNullOrWhiteSpace(query)) + Pages.AddRange(_items.Where(x => x.Header.Contains(query))); + else + Pages.AddRange(_items); + } + finally + { + _ignoreListChange = false; + if (_currentItem != null) + { + var newIndex = Pages.IndexOf(_currentItem); + if (newIndex != -1) + { + SelectedPageIndex = newIndex; + } + } + } + } + + public INavigation? Navigator { get; internal set; } + + public int SelectedPageIndex + { + get { return _selectedPageIndex; } + set + { + RaiseAndSetIfChanged(ref _selectedPageIndex, value); + + if (!_ignoreListChange) + { + NavigateTo(_selectedPageIndex); + + if (DisplayMode == SplitViewDisplayMode.CompactOverlay || DisplayMode == SplitViewDisplayMode.Overlay) + IsDrawerOpened = false; + } + } + } + + public bool IsDrawerOpened + { + get { return _isDrawerOpened; } + set { RaiseAndSetIfChanged(ref _isDrawerOpened, value); } + } + + public SplitViewDisplayMode DisplayMode + { + get { return _displayMode; } + set { RaiseAndSetIfChanged(ref _displayMode, value); } + } + + public string? Query + { + get { return _query; } + set + { + RaiseAndSetIfChanged(ref _query, value); + + Filter(value); + } + } + + private async void NavigateTo(int pageIndex) + { + if (pageIndex < 0 || pageIndex >= Pages.Count || Navigator is null) + return; + + var item = Pages[pageIndex]; + + if (item != null) + { + var view = item.Factory(); + if (view is Page page && view.GetType() != Navigator.NavigationStack.LastOrDefault()?.GetType()) + { + _currentItem = item; + await Navigator.ReplaceAsync(page); + } + } + } + } + + class PageItem(string header, Func factory, string? iconData = null) + { + public string Header { get; } = header; + public Func Factory { get; } = factory; + public string? IconData { get; } = iconData; + + public bool IsVisible { get; set; } = true; + } +} diff --git a/samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml b/samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml index d9b3e3c73f..b4d9900617 100644 --- a/samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml +++ b/samples/SampleControls/HamburgerMenu/HamburgerMenu.xaml @@ -33,8 +33,8 @@ #FFFFFFFF #FFF2F2F2 - - + + 40 220 36 @@ -134,14 +134,14 @@ - + diff --git a/src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml b/src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml index a3395ad99f..2a817ccfcb 100644 --- a/src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/PathIcon.xaml @@ -10,7 +10,6 @@ - diff --git a/src/Avalonia.Themes.Simple/Controls/PathIcon.xaml b/src/Avalonia.Themes.Simple/Controls/PathIcon.xaml index 9e39ba4645..9e451cf966 100644 --- a/src/Avalonia.Themes.Simple/Controls/PathIcon.xaml +++ b/src/Avalonia.Themes.Simple/Controls/PathIcon.xaml @@ -3,7 +3,6 @@ x:ClassModifier="internal"> - diff --git a/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs b/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs index 371cbe4d6d..e368d93892 100644 --- a/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs +++ b/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs @@ -3,9 +3,14 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using Avalonia.Controls; +using Avalonia.Controls.Presenters; using Avalonia.Controls.Primitives; +using Avalonia.Controls.Templates; using Avalonia.Input; using Avalonia.LogicalTree; +using Avalonia.Media; +using Avalonia.Styling; +using Avalonia.Themes.Simple; using Avalonia.Threading; using Avalonia.UnitTests; using Avalonia.VisualTree; @@ -118,6 +123,28 @@ public class CommandBarButtonTests : ScopedTestBase var btn = new CommandBarButton { CommandParameter = "param" }; Assert.Equal("param", btn.CommandParameter); } + + [Fact] + public void Foreground_DoesNotSetOrOverwriteIconElementForeground() + { + var icon = new PathIcon(); + var btn = new CommandBarButton + { + Icon = icon, + Foreground = Brushes.Red + }; + + Assert.False(icon.IsSet(TemplatedControl.ForegroundProperty)); + + btn.Foreground = Brushes.Blue; + + Assert.False(icon.IsSet(TemplatedControl.ForegroundProperty)); + + icon.Foreground = Brushes.Green; + btn.Foreground = Brushes.Red; + + Assert.Same(Brushes.Green, icon.Foreground); + } } public class CommandBarToggleButtonTests : ScopedTestBase @@ -205,6 +232,28 @@ public class CommandBarToggleButtonTests : ScopedTestBase var btn = new CommandBarToggleButton { CommandParameter = 42 }; Assert.Equal(42, btn.CommandParameter); } + + [Fact] + public void Foreground_DoesNotSetOrOverwriteIconElementForeground() + { + var icon = new PathIcon(); + var btn = new CommandBarToggleButton + { + Icon = icon, + Foreground = Brushes.Red + }; + + Assert.False(icon.IsSet(TemplatedControl.ForegroundProperty)); + + btn.Foreground = Brushes.Blue; + + Assert.False(icon.IsSet(TemplatedControl.ForegroundProperty)); + + icon.Foreground = Brushes.Green; + btn.Foreground = Brushes.Red; + + Assert.Same(Brushes.Green, icon.Foreground); + } } public class CommandBarSeparatorTests : ScopedTestBase @@ -309,6 +358,54 @@ public class CommandBarDefaultsTests : ScopedTestBase public void Content_DefaultIsNull() => Assert.Null(new CommandBar().Content); + [Fact] + public void Foreground_IsInheritedByCommandBarButtonPathIconThroughThemeTemplate() + { + using var app = UnitTestApplication.Start(TestServices.StyledWindow); + + var icon = new PathIcon(); + var btn = new CommandBarButton + { + Icon = icon + }; + var commandBar = new CommandBar + { + Foreground = Brushes.Red + }; + commandBar.PrimaryCommands.Add(btn); + + Assert.Same(icon, ApplySimpleThemeAndGetPresentedPathIcon(commandBar, btn)); + Assert.Same(Brushes.Red, icon.Foreground); + + commandBar.Foreground = Brushes.Blue; + + Assert.Same(Brushes.Blue, icon.Foreground); + } + + [Fact] + public void Foreground_IsInheritedByCommandBarToggleButtonPathIconThroughThemeTemplate() + { + using var app = UnitTestApplication.Start(TestServices.StyledWindow); + + var icon = new PathIcon(); + var btn = new CommandBarToggleButton + { + Icon = icon + }; + var commandBar = new CommandBar + { + Foreground = Brushes.Red + }; + commandBar.PrimaryCommands.Add(btn); + + Assert.Same(icon, ApplySimpleThemeAndGetPresentedPathIcon(commandBar, btn)); + Assert.Same(Brushes.Red, icon.Foreground); + + commandBar.Foreground = Brushes.Blue; + + Assert.Same(Brushes.Blue, icon.Foreground); + } + [Fact] public void PrimaryCommands_NotNull() => Assert.NotNull(new CommandBar().PrimaryCommands); @@ -370,6 +467,46 @@ public class CommandBarDefaultsTests : ScopedTestBase [Fact] public void ItemWidthCollapsed_DefaultIs42() => Assert.Equal(42d, new CommandBar().ItemWidthCollapsed); + + private static PathIcon ApplySimpleThemeAndGetPresentedPathIcon(CommandBar commandBar, TemplatedControl command) + { + var simpleTheme = new SimpleTheme(); + Assert.True(simpleTheme.TryGetResource(typeof(CommandBar), ThemeVariant.Default, out var commandBarTheme)); + Assert.True(simpleTheme.TryGetResource(command.GetType(), ThemeVariant.Default, out var commandTheme)); + commandBar.Theme = Assert.IsType(commandBarTheme); + command.Theme = Assert.IsType(commandTheme); + + var root = new TestRoot + { + Width = 500, + Height = 200, + Child = commandBar, + Styles = + { + simpleTheme + } + }; + + root.ApplyStyling(); + commandBar.ApplyStyling(); + commandBar.ApplyTemplate(); + root.LayoutManager.ExecuteInitialLayoutPass(); + + command.ApplyStyling(); + command.ApplyTemplate(); + + var presenter = command.GetTemplateChildren() + .OfType() + .Single(x => x.Name == "PART_IconPresenter"); + + presenter.ApplyStyling(); + presenter.UpdateChild(); + + var pathIcon = Assert.IsType(presenter.Child); + pathIcon.ApplyStyling(); + + return pathIcon; + } } public class CommandBarPropertyRoundTripTests : ScopedTestBase From dd9217ee9db26db057bcccd0ca7f9dcd567b1fb2 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Mon, 27 Apr 2026 09:47:48 +0200 Subject: [PATCH 45/60] Win32: fix BorderOnly maximized position on secondary screens in more cases (#21229) * Update IntegrationTests.Win32 to test all screens * Win32: use GetWindowPlacement to determine the screen to maximize to --- .../Avalonia.Win32/WindowImpl.AppWndProc.cs | 6 ++-- .../ExtendClientAreaWindowTests.cs | 35 +++++++++++-------- .../StandardWindowTests.cs | 34 +++++++++--------- .../UnmanagedMethods.cs | 5 +++ .../WindowExtensions.cs | 8 ++--- 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs index f003da9296..d9be50a967 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs @@ -852,9 +852,11 @@ namespace Avalonia.Win32 !_isFullScreenActive && !flags.HasAllFlags(SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE)) { - // Prefer ScreenFromRect as it contains the new position. + GetWindowPlacement(Hwnd, out var placement); + + // Prefer ScreenFromRect with the window's restored bounds. // If the window was minimized, ScreenFromHwnd won't return the correct monitor at this point. - var screen = Screen.ScreenFromRect(new PixelRect(pos->x, pos->y, pos->cx, pos->cy)) + var screen = Screen.ScreenFromRect(placement.NormalPosition.ToPixelRect()) ?? Screen.ScreenFromHwnd(Hwnd, MONITOR.MONITOR_DEFAULTTONEAREST); if (screen is not null) diff --git a/tests/Avalonia.IntegrationTests.Win32/ExtendClientAreaWindowTests.cs b/tests/Avalonia.IntegrationTests.Win32/ExtendClientAreaWindowTests.cs index 7c7d34ac14..2e94734d17 100644 --- a/tests/Avalonia.IntegrationTests.Win32/ExtendClientAreaWindowTests.cs +++ b/tests/Avalonia.IntegrationTests.Win32/ExtendClientAreaWindowTests.cs @@ -3,17 +3,17 @@ using System.Linq; using System.Threading.Tasks; using Avalonia.Automation; using Avalonia.Controls; -using Avalonia.Interactivity; using Avalonia.Media; using Avalonia.VisualTree; using Xunit; +using static Avalonia.IntegrationTests.Win32.UnmanagedMethods; namespace Avalonia.IntegrationTests.Win32; public abstract class ExtendClientAreaWindowTests : IDisposable { - private const double ClientWidth = 200; - private const double ClientHeight = 200; + private const int ClientWidth = 200; + private const int ClientHeight = 200; private Window? _window; @@ -28,10 +28,13 @@ public abstract class ExtendClientAreaWindowTests : IDisposable protected abstract WindowDecorations Decorations { get; } - public static MatrixTheoryData States - => new([true, false], Enum.GetValues()); + public static MatrixTheoryData States + => new( + Enumerable.Range(0, GetSystemMetrics(SM_CMONITORS)), + Enum.GetValues(), + [true, false]); - private async Task InitWindowAsync(WindowState state, bool canResize) + private async Task InitWindowAsync(int screenIndex, WindowState state, bool canResize) { Assert.Null(_window); @@ -44,7 +47,6 @@ public abstract class ExtendClientAreaWindowTests : IDisposable Width = ClientWidth, Height = ClientHeight, WindowStartupLocation = WindowStartupLocation.Manual, - Position = new PixelPoint(50, 50), Content = new Border { Background = Brushes.DodgerBlue, @@ -53,6 +55,9 @@ public abstract class ExtendClientAreaWindowTests : IDisposable } }; + var screenCenter = _window.Screens.All[screenIndex].Bounds.Center; + _window.Position = new PixelPoint(screenCenter.X - ClientWidth / 2, screenCenter.Y - ClientHeight / 2); + _window.Show(); await Window.WhenLoadedAsync(); @@ -60,9 +65,9 @@ public abstract class ExtendClientAreaWindowTests : IDisposable [Theory] [MemberData(nameof(States))] - public async Task Normal_State_Respects_Client_Size(bool canResize, WindowState initialState) + public async Task Normal_State_Respects_Client_Size(int screenIndex, WindowState initialState, bool canResize) { - await InitWindowAsync(initialState, canResize); + await InitWindowAsync(screenIndex, initialState, canResize); if (initialState != WindowState.Normal) Window.WindowState = WindowState.Normal; @@ -79,16 +84,16 @@ public abstract class ExtendClientAreaWindowTests : IDisposable [Theory] [MemberData(nameof(States))] - public async Task Maximized_State_Fills_Screen_Working_Area(bool canResize, WindowState initialState) + public async Task Maximized_State_Fills_Screen_Working_Area(int screenIndex, WindowState initialState, bool canResize) { - await InitWindowAsync(initialState, canResize); + await InitWindowAsync(screenIndex, initialState, canResize); if (initialState != WindowState.Maximized) Window.WindowState = WindowState.Maximized; // The client size should match the screen working area var clientSize = Window.GetWin32ClientSize(); - var screenWorkingArea = Window.GetScreen().WorkingArea; + var screenWorkingArea = Window.GetScreenAtIndex(screenIndex).WorkingArea; Assert.Equal(screenWorkingArea.Size, clientSize); VerifyMaximizedState(); @@ -98,16 +103,16 @@ public abstract class ExtendClientAreaWindowTests : IDisposable [Theory] [MemberData(nameof(States))] - public async Task FullScreen_State_Fills_Screen(bool canResize, WindowState initialState) + public async Task FullScreen_State_Fills_Screen(int screenIndex, WindowState initialState, bool canResize) { - await InitWindowAsync(initialState, canResize); + await InitWindowAsync(screenIndex, initialState, canResize); if (initialState != WindowState.FullScreen) Window.WindowState = WindowState.FullScreen; // The client size should match the screen bounds var clientSize = Window.GetWin32ClientSize(); - var screenBounds = Window.GetScreen().Bounds; + var screenBounds = Window.GetScreenAtIndex(screenIndex).Bounds; Assert.Equal(screenBounds.Width, clientSize.Width); Assert.Equal(screenBounds.Height, clientSize.Height); diff --git a/tests/Avalonia.IntegrationTests.Win32/StandardWindowTests.cs b/tests/Avalonia.IntegrationTests.Win32/StandardWindowTests.cs index 5971c4dc6c..233f69122b 100644 --- a/tests/Avalonia.IntegrationTests.Win32/StandardWindowTests.cs +++ b/tests/Avalonia.IntegrationTests.Win32/StandardWindowTests.cs @@ -2,19 +2,16 @@ using System.Linq; using System.Threading.Tasks; using Avalonia.Controls; -using Avalonia.Controls.Chrome; -using Avalonia.Interactivity; using Avalonia.Media; -using Avalonia.Platform; -using Avalonia.VisualTree; using Xunit; +using static Avalonia.IntegrationTests.Win32.UnmanagedMethods; namespace Avalonia.IntegrationTests.Win32; public abstract class StandardWindowTests : IDisposable { - private const double ClientWidth = 200; - private const double ClientHeight = 200; + private const int ClientWidth = 200; + private const int ClientHeight = 200; private Window? _window; @@ -31,10 +28,13 @@ public abstract class StandardWindowTests : IDisposable protected abstract bool HasCaption { get; } - public static MatrixTheoryData States - => new([true, false], Enum.GetValues()); + public static MatrixTheoryData States + => new( + Enumerable.Range(0, GetSystemMetrics(SM_CMONITORS)), + Enum.GetValues(), + [true, false]); - private async Task InitWindowAsync(WindowState state, bool canResize) + private async Task InitWindowAsync(int screenIndex, WindowState state, bool canResize) { Assert.Null(_window); @@ -47,7 +47,6 @@ public abstract class StandardWindowTests : IDisposable Width = ClientWidth, Height = ClientHeight, WindowStartupLocation = WindowStartupLocation.Manual, - Position = new PixelPoint(50, 50), Content = new Border { Background = Brushes.DodgerBlue, @@ -56,6 +55,9 @@ public abstract class StandardWindowTests : IDisposable } }; + var screenCenter = _window.Screens.All[screenIndex].Bounds.Center; + _window.Position = new PixelPoint(screenCenter.X - ClientWidth / 2, screenCenter.Y - ClientHeight / 2); + _window.Show(); await Window.WhenLoadedAsync(); @@ -63,16 +65,16 @@ public abstract class StandardWindowTests : IDisposable [Theory] [MemberData(nameof(States))] - public async Task Maximized_State_Fills_Screen_Working_Area(bool canResize, WindowState initialState) + public async Task Maximized_State_Fills_Screen_Working_Area(int screenIndex, WindowState initialState, bool canResize) { - await InitWindowAsync(initialState, canResize); + await InitWindowAsync(screenIndex, initialState, canResize); if (initialState != WindowState.Maximized) Window.WindowState = WindowState.Maximized; // The client size should match the screen working area var clientSize = Window.GetWin32ClientSize(); - var screenWorkingArea = Window.GetScreen().WorkingArea; + var screenWorkingArea = Window.GetScreenAtIndex(screenIndex).WorkingArea; if (HasCaption) { @@ -85,16 +87,16 @@ public abstract class StandardWindowTests : IDisposable [Theory] [MemberData(nameof(States))] - public async Task FullScreen_State_Fills_Screen(bool canResize, WindowState initialState) + public async Task FullScreen_State_Fills_Screen(int screenIndex, WindowState initialState, bool canResize) { - await InitWindowAsync(initialState, canResize); + await InitWindowAsync(screenIndex, initialState, canResize); if (initialState != WindowState.FullScreen) Window.WindowState = WindowState.FullScreen; // The client size should match the screen bounds var clientSize = Window.GetWin32ClientSize(); - var screenBounds = Window.GetScreen().Bounds; + var screenBounds = Window.GetScreenAtIndex(screenIndex).Bounds; Assert.Equal(screenBounds.Width, clientSize.Width); Assert.Equal(screenBounds.Height, clientSize.Height); diff --git a/tests/Avalonia.IntegrationTests.Win32/UnmanagedMethods.cs b/tests/Avalonia.IntegrationTests.Win32/UnmanagedMethods.cs index 591ed182c4..4f4f4c03d0 100644 --- a/tests/Avalonia.IntegrationTests.Win32/UnmanagedMethods.cs +++ b/tests/Avalonia.IntegrationTests.Win32/UnmanagedMethods.cs @@ -13,6 +13,9 @@ internal static partial class UnmanagedMethods [return: MarshalAs(UnmanagedType.Bool)] public static partial bool GetWindowRect(IntPtr hwnd, out RECT lpRect); + [LibraryImport("user32.dll")] + public static partial int GetSystemMetrics(int nIndex); + public struct RECT { public int left; @@ -20,4 +23,6 @@ internal static partial class UnmanagedMethods public int right; public int bottom; } + + public const int SM_CMONITORS = 80; } diff --git a/tests/Avalonia.IntegrationTests.Win32/WindowExtensions.cs b/tests/Avalonia.IntegrationTests.Win32/WindowExtensions.cs index 1d92324961..acf154ddde 100644 --- a/tests/Avalonia.IntegrationTests.Win32/WindowExtensions.cs +++ b/tests/Avalonia.IntegrationTests.Win32/WindowExtensions.cs @@ -27,12 +27,8 @@ internal static class WindowExtensions } } - public static Screen GetScreen(this Window window) - { - var screen = window.Screens.ScreenFromWindow(window); - Assert.NotNull(screen); - return screen; - } + public static Screen GetScreenAtIndex(this Window window, int index) + => window.Screens.All[index]; public static PixelSize GetWin32ClientSize(this Window window) { From 009d75af98d3b091f22e01aa8ef78657c092c932 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Mon, 27 Apr 2026 09:47:58 +0200 Subject: [PATCH 46/60] Fix FocusManager.SetFocusScope not doing anything (#21261) * Add failing test for SetFocusScope * Fix FocusManager.SetFocusScope not doing anything --- src/Avalonia.Base/Input/FocusManager.cs | 10 ++++++ .../Input/InputElement_Focus.cs | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/Avalonia.Base/Input/FocusManager.cs b/src/Avalonia.Base/Input/FocusManager.cs index 72a13d385d..5b046ab682 100644 --- a/src/Avalonia.Base/Input/FocusManager.cs +++ b/src/Avalonia.Base/Input/FocusManager.cs @@ -142,6 +142,9 @@ namespace Avalonia.Input [PrivateApi] public void SetFocusScope(IFocusScope scope) { + if (KeyboardDevice.Instance is not { } keyboardDevice) + return; + if (GetFocusedElement(scope) is { } focused) { Focus(focused); @@ -153,6 +156,13 @@ namespace Avalonia.Input // focus etc. Focus(scopeElement); } + else + { + // If the scope isn't focusable, make sure we still set it as the current focus root, + // otherwise it will be completely ignored + _focusRoot = scope as StyledElement; + keyboardDevice.SetFocusedElement(null, NavigationMethod.Unspecified, KeyModifiers.None, false); + } } [PrivateApi] diff --git a/tests/Avalonia.Base.UnitTests/Input/InputElement_Focus.cs b/tests/Avalonia.Base.UnitTests/Input/InputElement_Focus.cs index 9e835b2427..580c80e79f 100644 --- a/tests/Avalonia.Base.UnitTests/Input/InputElement_Focus.cs +++ b/tests/Avalonia.Base.UnitTests/Input/InputElement_Focus.cs @@ -703,6 +703,41 @@ namespace Avalonia.Base.UnitTests.Input Assert.Same(innerButton, focusManager.GetFocusedElement()); } + // https://github.com/AvaloniaUI/Avalonia/issues/13134 + [Fact] + public void SetFocusScope_On_Non_Focusable_Scope_Changes_Scope() + { + using var app = UnitTestApplication.Start(TestServices.RealFocus); + + Button outerButton; + TestFocusScope innerScope; + var root = new TestRoot + { + Child = new StackPanel + { + Focusable = false, + Children = + { + (innerScope = new TestFocusScope()), + (outerButton = new Button()) + } + } + }; + + outerButton.Focus(); + + var focusManager = Assert.IsType(root.FocusManager); + Assert.Same(outerButton, focusManager.GetFocusedElement()); + + // Switch to a scope that has no previously focused element and isn't focusable itself. + // TestFocusScope is a Panel (Focusable = false) + IFocusScope. + focusManager.SetFocusScope(innerScope); + + // Focus must be cleared: the scope is not focusable and has no prior focused element. + // Before the fix this was a no-op and outerButton would still be reported as focused. + Assert.Null(focusManager.GetFocusedElement()); + } + [Fact] public void Can_Get_First_Focusable_Element() { From db2b01bc01885283757c967dffc75f770b7ea41e Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Mon, 27 Apr 2026 12:32:52 +0200 Subject: [PATCH 47/60] Clarify that ElementRole is dependent on ExtendClientAreaToDecorationsHint (#21243) --- src/Avalonia.Controls/Chrome/WindowDecorationProperties.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Avalonia.Controls/Chrome/WindowDecorationProperties.cs b/src/Avalonia.Controls/Chrome/WindowDecorationProperties.cs index 5ad874eec4..0881dda57f 100644 --- a/src/Avalonia.Controls/Chrome/WindowDecorationProperties.cs +++ b/src/Avalonia.Controls/Chrome/WindowDecorationProperties.cs @@ -12,6 +12,7 @@ public static class WindowDecorationProperties /// Marks a visual element with a specific role for non-client hit-testing. /// Can be applied to any element in the visual tree, not limited to decoration children. /// + /// Setting an element role only has an effect if is true. public static readonly AttachedProperty ElementRoleProperty = AvaloniaProperty.RegisterAttached("ElementRole", typeof(WindowDecorationProperties)); @@ -23,5 +24,6 @@ public static class WindowDecorationProperties /// /// Sets the for the specified element. /// + /// Setting an element role only has an effect if is true. public static void SetElementRole(Visual element, WindowDecorationsElementRole value) => element.SetValue(ElementRoleProperty, value); } From 65dc74c39f10b324bee7c1ed4c25b0b06ccd0910 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Mon, 27 Apr 2026 10:54:09 +0000 Subject: [PATCH 48/60] [ANDROID] Make ToplevelImpl._view nullable. (#21270) * mark ToplevelImpl._view as nullable. * Update src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs Co-authored-by: Max Katz * return 1 as default scaling in android TopLevelImpl --------- Co-authored-by: Max Katz --- src/Android/Avalonia.Android/AvaloniaView.cs | 6 ++-- .../Platform/AndroidScreens.cs | 2 +- .../Platform/SkiaPlatform/TopLevelImpl.cs | 36 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Android/Avalonia.Android/AvaloniaView.cs b/src/Android/Avalonia.Android/AvaloniaView.cs index d8df486bb3..f1c3b95aa1 100644 --- a/src/Android/Avalonia.Android/AvaloniaView.cs +++ b/src/Android/Avalonia.Android/AvaloniaView.cs @@ -35,10 +35,10 @@ namespace Avalonia.Android _root = new EmbeddableControlRoot(_view); _root.Prepare(); - this.SetBackgroundColor(global::Android.Graphics.Color.Transparent); + SetBackgroundColor(global::Android.Graphics.Color.Transparent); OnConfigurationChanged(); - _view.InternalView.SurfaceWindowCreated += InternalView_SurfaceWindowCreated; + _view.InternalView!.SurfaceWindowCreated += InternalView_SurfaceWindowCreated; _view.InternalView.SurfaceWindowDestroyed += InternalView_SurfaceWindowDestroyed; _accessHelper = new AvaloniaAccessHelper(this); @@ -141,7 +141,7 @@ namespace Avalonia.Android { public ViewImpl(AvaloniaView avaloniaView) : base(avaloniaView) { - View.FocusChange += ViewImpl_FocusChange; + View!.FocusChange += ViewImpl_FocusChange; } private void ViewImpl_FocusChange(object? sender, FocusChangeEventArgs e) diff --git a/src/Android/Avalonia.Android/Platform/AndroidScreens.cs b/src/Android/Avalonia.Android/Platform/AndroidScreens.cs index 9b0f1bee38..a54a4cbdb8 100644 --- a/src/Android/Avalonia.Android/Platform/AndroidScreens.cs +++ b/src/Android/Avalonia.Android/Platform/AndroidScreens.cs @@ -125,7 +125,7 @@ internal sealed class AndroidScreens : ScreensBase, IDis protected override Screen? ScreenFromTopLevelCore(ITopLevelImpl topLevel) { - var display = ((TopLevelImpl)topLevel).View.Display; + var display = ((TopLevelImpl)topLevel).View?.Display; return display is not null && TryGetScreen(display, out var screen) ? screen : null; } diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index da128cec96..eecb2ecc24 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -19,8 +19,8 @@ using Avalonia.Input.Raw; using Avalonia.Input.TextInput; using Avalonia.OpenGL.Egl; using Avalonia.Platform; -using Avalonia.Platform.Surfaces; using Avalonia.Platform.Storage; +using Avalonia.Platform.Surfaces; using Avalonia.Rendering.Composition; using Java.Lang; using ClipboardManager = Android.Content.ClipboardManager; @@ -39,7 +39,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform private readonly Clipboard _clipboard; private readonly AndroidLauncher? _launcher; private readonly AndroidScreens? _screens; - private SurfaceViewImpl _view; + private SurfaceViewImpl? _view; private WindowTransparencyLevel _transparencyLevel; public TopLevelImpl(AvaloniaView avaloniaView, bool placeOnTop = false) @@ -78,8 +78,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform public IInputRoot? InputRoot { get; private set; } - public Size ClientSize => _view.Size.ToSize(RenderScaling); - public double RenderScaling => _view.Scaling; + public Size ClientSize => _view?.Size.ToSize(RenderScaling) ?? default; + public double RenderScaling => _view?.Scaling ?? 1; public Action? Closed { get; set; } @@ -91,9 +91,9 @@ namespace Avalonia.Android.Platform.SkiaPlatform public Action? ScalingChanged { get; set; } - public View View => _view; + public View? View => _view; - internal InvalidationAwareSurfaceView InternalView => _view; + internal InvalidationAwareSurfaceView? InternalView => _view; public double DesktopScaling => RenderScaling; public IPlatformHandle Handle { get; } @@ -126,8 +126,8 @@ namespace Avalonia.Android.Platform.SkiaPlatform public virtual void Dispose() { _systemNavigationManager.Dispose(); - _view.Dispose(); - _view = null!; + _view?.Dispose(); + _view = null; } protected void OnResized(Size size) @@ -193,7 +193,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform // ReSharper disable once CompareOfFloatsByEqualityOperator if (newScaling != _oldScaling) { - _oldScaling = newScaling; + _oldScaling = newScaling; _tl.ScalingChanged?.Invoke(newScaling); } } @@ -232,7 +232,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform public void SetFrameThemeVariant(PlatformThemeVariant themeVariant) { - if(_insetsManager != null) + if (_insetsManager != null) { _insetsManager.SystemBarTheme = themeVariant switch { @@ -245,12 +245,12 @@ namespace Avalonia.Android.Platform.SkiaPlatform AppCompatDelegate.DefaultNightMode = themeVariant == PlatformThemeVariant.Light ? AppCompatDelegate.ModeNightNo : AppCompatDelegate.ModeNightYes; } - public AcrylicPlatformCompensationLevels AcrylicCompensationLevels => new AcrylicPlatformCompensationLevels(1, 1, 1); + public AcrylicPlatformCompensationLevels AcrylicCompensationLevels => new(1, 1, 1); - IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => ((IPlatformHandle)_view).Handle; + IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => (_view as IPlatformHandle)?.Handle ?? default; bool EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfoWithWaitPolicy.SkipWaits => true; - PixelSize EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Size => _view.Size; - double EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Scaling => _view.Scaling; + PixelSize EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Size => _view?.Size ?? default; + double EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Scaling => _view?.Scaling ?? default; internal AndroidKeyboardEventsHelper KeyboardHelper => _keyboardHelper; @@ -258,7 +258,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform public void SetTransparencyLevelHint(IReadOnlyList transparencyLevels) { - if (_view.Context is not AvaloniaActivity activity) + if (_view?.Context is not AvaloniaActivity activity) return; foreach (var level in transparencyLevels) @@ -341,7 +341,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform return _insetsManager; } - if(featureType == typeof(IClipboard)) + if (featureType == typeof(IClipboard)) { return _clipboard; } @@ -355,7 +355,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform { return _screens; } - + return null; } @@ -386,7 +386,7 @@ namespace Avalonia.Android.Platform.SkiaPlatform internal void TextInput(string text) { - if(Input != null) + if (Input != null) { var args = new RawTextInputEventArgs(AndroidKeyboardDevice.Instance!, (ulong)SystemClock.UptimeMillis(), InputRoot!, text); From c0a41d8812f862fec1dc5a6bb700748e1076d959 Mon Sep 17 00:00:00 2001 From: Nicolas Musset Date: Mon, 27 Apr 2026 13:25:58 +0200 Subject: [PATCH 49/60] Fix headless cleanup race: dispose before signalling TCS (#20664) (#21223) * Fix headless cleanup race: dispose before signalling TCS (#20664) Restructure DispatchCore so application.Dispose() runs in a finally block before tcs.TrySet* is called. Previously, the using-var scope closed after TrySetResult, leaving s_uiThread set when the next non-headless test started. Adds a regression test in IsolationTests that verifies Dispatcher.UIThread is accessible from the calling thread immediately after a headless dispatch completes (PerTest isolation only). * Use Assert.SkipWhen in Dispatch_Cleanup_Should_Complete_Before_Task_Returns * Restrict Dispatch_Cleanup_Should_Complete_Before_Task_Returns to NUnit xUnit's AvaloniaFactDiscoverer wraps every [Fact] in session.Dispatch, so awaiting another session.Dispatch inside the test body deadlocks on the session's single background thread. * Remove new test It isn't reliable enough during CI. --------- Co-authored-by: Jumar Macato <16554748+jmacato@users.noreply.github.com> --- .../HeadlessUnitTestSession.cs | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/Headless/Avalonia.Headless/HeadlessUnitTestSession.cs b/src/Headless/Avalonia.Headless/HeadlessUnitTestSession.cs index cda9c4ae75..0d48dd6919 100644 --- a/src/Headless/Avalonia.Headless/HeadlessUnitTestSession.cs +++ b/src/Headless/Avalonia.Headless/HeadlessUnitTestSession.cs @@ -96,11 +96,16 @@ public sealed class HeadlessUnitTestSession : IDisposable, IAsyncDisposable using var globalCts = token.Register(s => ((CancellationTokenSource)s!).Cancel(), cts, true); using var localCts = cancellationToken.Register(s => ((CancellationTokenSource)s!).Cancel(), cts, true); + var application = _isolated + ? EnsureIsolatedApplication() + : EnsureSharedApplication(); + + bool shouldCancel = false; + Exception? caught = null; + TResult result = default!; + try { - using var application = _isolated - ? EnsureIsolatedApplication() - : EnsureSharedApplication(); var task = action(); if (task.Status != TaskStatus.RanToCompletion) { @@ -110,22 +115,36 @@ public sealed class HeadlessUnitTestSession : IDisposable, IAsyncDisposable if (cts.IsCancellationRequested) { - tcs.TrySetCanceled(cts.Token); - return; + shouldCancel = true; + } + else + { + var frame = new DispatcherFrame(); + using var innerCts = cts.Token.Register(() => frame.Continue = false, true); + Dispatcher.UIThread.PushFrame(frame); + result = task.GetAwaiter().GetResult(); } - - var frame = new DispatcherFrame(); - using var innerCts = cts.Token.Register(() => frame.Continue = false, true); - Dispatcher.UIThread.PushFrame(frame); } - - var result = task.GetAwaiter().GetResult(); - tcs.TrySetResult(result); + else + { + result = task.GetAwaiter().GetResult(); + } } catch (Exception ex) { - tcs.TrySetException(ex); + caught = ex; } + finally + { + application.Dispose(); + } + + if (caught != null) + tcs.TrySetException(caught); + else if (shouldCancel) + tcs.TrySetCanceled(cts.Token); + else + tcs.TrySetResult(result); }, executionContext)); return tcs.Task; } From 5e2f4ccd4942c425d7043f2974332b1d5a99c302 Mon Sep 17 00:00:00 2001 From: Julien Lebosquain Date: Mon, 27 Apr 2026 13:55:59 +0200 Subject: [PATCH 50/60] Implement GetTemplateDescendants (#21245) * Implement GetTemplateDescendants * Use GetTemplateDescendants in Avalonia.Controls * Use GetTemplateDescendants in tests * Fix obsolete warnings --- .../Primitives/LightDismissOverlayLayer.cs | 2 +- .../Primitives/TemplatedControl.cs | 8 ++-- .../Templates/TemplateExtensions.cs | 37 +++++++++++++++---- .../Layout/FullLayoutTests.cs | 4 +- .../AutoCompleteBoxTests.cs | 2 +- .../CalendarDatePickerTests.cs | 2 +- .../ComboBoxTests.cs | 2 +- .../CommandBarTests.cs | 2 +- .../ContentControlTests.cs | 2 +- .../NumericUpDownTests.cs | 4 +- .../Primitives/PopupTests.cs | 6 +-- .../Primitives/ScrollBarTests.cs | 10 ++--- .../Primitives/TemplatedControlTests.cs | 8 ++-- .../ScrollViewerTests.cs | 4 +- .../TabControlTests.cs | 6 +-- .../Templates/TemplateExtensionsTests.cs | 2 +- .../TransitioningContentControlTests.cs | 2 +- tests/Avalonia.LeakTests/ControlTests.cs | 2 +- .../Data/BindingTests_TemplatedParent.cs | 2 +- .../CompiledBindingExtensionTests.cs | 8 ++-- 20 files changed, 68 insertions(+), 47 deletions(-) diff --git a/src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs b/src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs index 2e4a1a4828..4662d2532e 100644 --- a/src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs +++ b/src/Avalonia.Controls/Primitives/LightDismissOverlayLayer.cs @@ -34,7 +34,7 @@ namespace Avalonia.Controls.Primitives if (visual is TopLevel topLevel) { - manager = topLevel.GetTemplateChildren() + manager = topLevel.GetTemplateDescendants() .OfType() .FirstOrDefault(); } diff --git a/src/Avalonia.Controls/Primitives/TemplatedControl.cs b/src/Avalonia.Controls/Primitives/TemplatedControl.cs index d8ecfa99e8..80f4aa572e 100644 --- a/src/Avalonia.Controls/Primitives/TemplatedControl.cs +++ b/src/Avalonia.Controls/Primitives/TemplatedControl.cs @@ -317,7 +317,7 @@ namespace Avalonia.Controls.Primitives { if (VisualChildren.Count > 0) { - foreach (var child in this.GetTemplateChildren()) + foreach (var child in this.GetTemplateDescendants()) { child.TemplatedParent = null; ((ISetLogicalParent)child).SetParent(null); @@ -350,11 +350,11 @@ namespace Avalonia.Controls.Primitives /// protected override Control GetTemplateFocusTarget() { - foreach (Control child in this.GetTemplateChildren()) + foreach (var child in this.GetTemplateDescendants()) { - if (GetIsTemplateFocusTarget(child)) + if (child is Control control && GetIsTemplateFocusTarget(control)) { - return child; + return control; } } diff --git a/src/Avalonia.Controls/Templates/TemplateExtensions.cs b/src/Avalonia.Controls/Templates/TemplateExtensions.cs index b8d90ae458..6d10244ba4 100644 --- a/src/Avalonia.Controls/Templates/TemplateExtensions.cs +++ b/src/Avalonia.Controls/Templates/TemplateExtensions.cs @@ -1,26 +1,47 @@ using System; using System.Collections.Generic; -using System.Linq; -using Avalonia.Controls; using Avalonia.Controls.Primitives; -using Avalonia.Styling; using Avalonia.VisualTree; namespace Avalonia.Controls.Templates { + /// + /// Contains extension methods for . + /// public static class TemplateExtensions { + /// + /// Gets the list of all control descendants that are part of the template of a , + /// i.e. their is . + /// + /// The control whose descendants will be returned. + /// An enumeration of objects. + [Obsolete($"Use {nameof(GetTemplateDescendants)}")] public static IEnumerable GetTemplateChildren(this TemplatedControl control) { - foreach (Control child in GetTemplateChildren(control, control)) + foreach (var child in control.GetTemplateDescendants()) { - yield return child; + if (child is Control childControl) + { + yield return childControl; + } } } - private static IEnumerable GetTemplateChildren(Control control, TemplatedControl templatedParent) + /// + /// Gets the list of all visual descendants that are part of the template of a , + /// i.e. their is . + /// + /// The control whose descendants will be returned. + /// An enumeration of objects. + public static IEnumerable GetTemplateDescendants(this TemplatedControl control) + { + return GetTemplateDescendants(control, control); + } + + private static IEnumerable GetTemplateDescendants(Visual control, TemplatedControl templatedParent) { - foreach (Control child in control.GetVisualChildren()) + foreach (var child in control.GetVisualChildren()) { var childTemplatedParent = child.TemplatedParent; @@ -31,7 +52,7 @@ namespace Avalonia.Controls.Templates if (childTemplatedParent != null) { - foreach (var descendant in GetTemplateChildren(child, templatedParent)) + foreach (var descendant in GetTemplateDescendants(child, templatedParent)) { yield return descendant; } diff --git a/tests/Avalonia.Base.UnitTests/Layout/FullLayoutTests.cs b/tests/Avalonia.Base.UnitTests/Layout/FullLayoutTests.cs index 4922fbe37b..2daedca80c 100644 --- a/tests/Avalonia.Base.UnitTests/Layout/FullLayoutTests.cs +++ b/tests/Avalonia.Base.UnitTests/Layout/FullLayoutTests.cs @@ -86,8 +86,8 @@ namespace Avalonia.Base.UnitTests.Layout Assert.Equal(new Point(300, 200), Position(scrollViewer)); Assert.Equal(new Size(400, 400), textBlock.Bounds.Size); - var scrollBars = scrollViewer.GetTemplateChildren().OfType().ToList(); - var presenters = scrollViewer.GetTemplateChildren().OfType().ToList(); + var scrollBars = scrollViewer.GetTemplateDescendants().OfType().ToList(); + var presenters = scrollViewer.GetTemplateDescendants().OfType().ToList(); Assert.Equal(2, scrollBars.Count); Assert.Single(presenters); diff --git a/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs b/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs index 3bdec3bc7e..4232624fad 100644 --- a/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs @@ -1235,7 +1235,7 @@ namespace Avalonia.Controls.UnitTests } private TextBox GetTextBox(AutoCompleteBox control) { - return control.GetTemplateChildren() + return control.GetTemplateDescendants() .OfType() .First(); } diff --git a/tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs b/tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs index d97a9729fb..b620601f71 100644 --- a/tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs +++ b/tests/Avalonia.Controls.UnitTests/CalendarDatePickerTests.cs @@ -155,7 +155,7 @@ namespace Avalonia.Controls.UnitTests private TextBox GetTextBox(CalendarDatePicker control) { - return control.GetTemplateChildren() + return control.GetTemplateDescendants() .OfType() .First(); } diff --git a/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs b/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs index 578484557f..b3212ed0f7 100644 --- a/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs @@ -834,7 +834,7 @@ namespace Avalonia.Controls.UnitTests target.ApplyTemplate(); target.Presenter!.ApplyTemplate(); - var containerPanel = target.GetTemplateChildren().OfType().FirstOrDefault(x => x.Name == "container"); + var containerPanel = target.GetTemplateDescendants().OfType().FirstOrDefault(x => x.Name == "container"); var editableTextBox = containerPanel?.GetVisualDescendants().OfType().FirstOrDefault(x => x.Name == "PART_EditableTextBox"); var popup = containerPanel?.GetVisualDescendants().OfType().FirstOrDefault(x => x.Name == "PART_Popup"); var popupScrollViewer = popup?.Child as ScrollViewer; diff --git a/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs b/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs index e368d93892..a7996a46ca 100644 --- a/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs +++ b/tests/Avalonia.Controls.UnitTests/CommandBarTests.cs @@ -495,7 +495,7 @@ public class CommandBarDefaultsTests : ScopedTestBase command.ApplyStyling(); command.ApplyTemplate(); - var presenter = command.GetTemplateChildren() + var presenter = command.GetTemplateDescendants() .OfType() .Single(x => x.Name == "PART_IconPresenter"); diff --git a/tests/Avalonia.Controls.UnitTests/ContentControlTests.cs b/tests/Avalonia.Controls.UnitTests/ContentControlTests.cs index 30d789f08f..87eb4ef2af 100644 --- a/tests/Avalonia.Controls.UnitTests/ContentControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ContentControlTests.cs @@ -57,7 +57,7 @@ namespace Avalonia.Controls.UnitTests target.ApplyTemplate(); target.Presenter!.ApplyTemplate(); - foreach (Control child in target.GetTemplateChildren()) + foreach (var child in target.GetTemplateDescendants().OfType()) Assert.Equal("foo", child.Tag); } diff --git a/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs b/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs index 868b33d7bd..b1a402435d 100644 --- a/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs +++ b/tests/Avalonia.Controls.UnitTests/NumericUpDownTests.cs @@ -142,7 +142,7 @@ namespace Avalonia.Controls.UnitTests } private static TextBox GetTextBox(NumericUpDown control) { - return control.GetTemplateChildren() + return control.GetTemplateDescendants() .OfType() .Select(b => b.Content) .OfType() @@ -151,7 +151,7 @@ namespace Avalonia.Controls.UnitTests private static ButtonSpinner GetSpinner(NumericUpDown control) { - return control.GetTemplateChildren() + return control.GetTemplateDescendants() .OfType() .First(); } diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs index ca38a56166..dcf9b6f653 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/PopupTests.cs @@ -329,7 +329,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var popup = (Popup)target.GetTemplateChildren().First(x => x.Name == "popup"); + var popup = (Popup)target.GetTemplateDescendants().First(x => x.Name == "popup"); popup.Open(); var popupRoot = (Control)popup.Host!; @@ -420,7 +420,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var popup = (Popup)target.GetTemplateChildren().First(x => x.Name == "popup"); + var popup = (Popup)target.GetTemplateDescendants().First(x => x.Name == "popup"); popup.Open(); var popupRoot = (Control)popup.Host!; @@ -515,7 +515,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var popup = (Popup)target.GetTemplateChildren().First(x => x.Name == "popup"); + var popup = (Popup)target.GetTemplateDescendants().First(x => x.Name == "popup"); popup.Open(); var popupRoot = (Control)popup.Host!; diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs index 215cdb64b3..b6bfab09cc 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs @@ -20,7 +20,7 @@ namespace Avalonia.Controls.UnitTests.Primitives }; target.ApplyTemplate(); - var track = (Track)target.GetTemplateChildren().First(x => x.Name == "track"); + var track = (Track)target.GetTemplateDescendants().First(x => x.Name == "track"); target.Value = 50; Assert.Equal(50, track.Value); @@ -35,7 +35,7 @@ namespace Avalonia.Controls.UnitTests.Primitives }; target.ApplyTemplate(); - var track = (Track)target.GetTemplateChildren().First(x => x.Name == "track"); + var track = (Track)target.GetTemplateDescendants().First(x => x.Name == "track"); track.Value = 50; Assert.Equal(50, target.Value); @@ -51,7 +51,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var track = (Track)target.GetTemplateChildren().First(x => x.Name == "track"); + var track = (Track)target.GetTemplateDescendants().First(x => x.Name == "track"); target.Value = 25; track.Value = 50; @@ -68,7 +68,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var track = (Track)target.GetTemplateChildren().First(x => x.Name == "track"); + var track = (Track)target.GetTemplateDescendants().First(x => x.Name == "track"); var raisedEvent = Assert.Raises( handler => target.Scroll += handler, @@ -97,7 +97,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var track = (Track)target.GetTemplateChildren().First(x => x.Name == "track"); + var track = (Track)target.GetTemplateDescendants().First(x => x.Name == "track"); var raisedEvent = Assert.Raises( handler => target.Scroll += handler, diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs index 721ad45c11..8a35a75dc4 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/TemplatedControlTests.cs @@ -204,7 +204,7 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - foreach (Control child in target.GetTemplateChildren()) + foreach (var child in target.GetTemplateDescendants().OfType()) Assert.Equal("foo", child.Tag); } @@ -237,11 +237,11 @@ namespace Avalonia.Controls.UnitTests.Primitives target.ApplyTemplate(); - var contentControl = target.GetTemplateChildren().OfType().Single(); + var contentControl = target.GetTemplateDescendants().OfType().Single(); contentControl.ApplyTemplate(); - var border = contentControl.GetTemplateChildren().OfType().Single(); - var presenter = contentControl.GetTemplateChildren().OfType().Single(); + var border = contentControl.GetTemplateDescendants().OfType().Single(); + var presenter = contentControl.GetTemplateDescendants().OfType().Single(); var decorator = (Decorator)presenter.Content!; var textBlock = (TextBlock)decorator.Child!; diff --git a/tests/Avalonia.Controls.UnitTests/ScrollViewerTests.cs b/tests/Avalonia.Controls.UnitTests/ScrollViewerTests.cs index e71f4bd8b7..ec1cd5fb66 100644 --- a/tests/Avalonia.Controls.UnitTests/ScrollViewerTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ScrollViewerTests.cs @@ -610,9 +610,9 @@ namespace Avalonia.Controls.UnitTests private Thumb GetVerticalThumb(ScrollViewer target) { var scrollbar = Assert.IsType( - target.GetTemplateChildren().FirstOrDefault(x => x.Name == "PART_VerticalScrollBar")); + target.GetTemplateDescendants().FirstOrDefault(x => x.Name == "PART_VerticalScrollBar")); var track = Assert.IsType( - scrollbar.GetTemplateChildren().FirstOrDefault(x => x.Name == "track")); + scrollbar.GetTemplateDescendants().FirstOrDefault(x => x.Name == "track")); return Assert.IsType(track.Thumb); } diff --git a/tests/Avalonia.Controls.UnitTests/TabControlTests.cs b/tests/Avalonia.Controls.UnitTests/TabControlTests.cs index 06a7054766..ea14eb5b2f 100644 --- a/tests/Avalonia.Controls.UnitTests/TabControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TabControlTests.cs @@ -1701,7 +1701,7 @@ namespace Avalonia.Controls.UnitTests tabItem.ApplyTemplate(); tabItem.Presenter!.UpdateChild(); - var iconPresenter = tabItem.GetTemplateChildren().OfType().First(x => x.Name == "PART_IconPresenter"); + var iconPresenter = tabItem.GetTemplateDescendants().OfType().First(x => x.Name == "PART_IconPresenter"); Assert.NotNull(iconPresenter); Assert.Equal("home", iconPresenter!.Content); Assert.NotNull(iconPresenter.ContentTemplate); @@ -1729,7 +1729,7 @@ namespace Avalonia.Controls.UnitTests tabItem.ApplyTemplate(); tabItem.Presenter!.UpdateChild(); - var iconPresenter = tabItem.GetTemplateChildren().OfType().First(x => x.Name == "PART_IconPresenter"); + var iconPresenter = tabItem.GetTemplateDescendants().OfType().First(x => x.Name == "PART_IconPresenter"); Assert.NotNull(iconPresenter); Assert.Same(icon, iconPresenter!.Content); Assert.Null(iconPresenter.ContentTemplate); @@ -1748,7 +1748,7 @@ namespace Avalonia.Controls.UnitTests tabItem.ApplyTemplate(); tabItem.Presenter!.UpdateChild(); - var iconPresenter = tabItem.GetTemplateChildren().OfType().First(x => x.Name == "PART_IconPresenter"); + var iconPresenter = tabItem.GetTemplateDescendants().OfType().First(x => x.Name == "PART_IconPresenter"); Assert.Equal("first", iconPresenter!.Content); tabItem.Icon = "second"; diff --git a/tests/Avalonia.Controls.UnitTests/Templates/TemplateExtensionsTests.cs b/tests/Avalonia.Controls.UnitTests/Templates/TemplateExtensionsTests.cs index d540ae9444..734c2a916d 100644 --- a/tests/Avalonia.Controls.UnitTests/Templates/TemplateExtensionsTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Templates/TemplateExtensionsTests.cs @@ -38,7 +38,7 @@ namespace Avalonia.Controls.Templates.UnitTests border3.Child = border4; border4.Child = border5; - var result = target.GetTemplateChildren().Select(x => x.Name).ToArray(); + var result = target.GetTemplateDescendants().Select(x => x.Name).ToArray(); Assert.Equal(new[] { "border1", "inner", "border4" }, result); } diff --git a/tests/Avalonia.Controls.UnitTests/TransitioningContentControlTests.cs b/tests/Avalonia.Controls.UnitTests/TransitioningContentControlTests.cs index b84fef1fb2..7f42e20307 100644 --- a/tests/Avalonia.Controls.UnitTests/TransitioningContentControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TransitioningContentControlTests.cs @@ -371,7 +371,7 @@ namespace Avalonia.Controls.UnitTests private static ContentPresenter GetContentPresenters2(TransitioningContentControl target) { return Assert.IsType(target - .GetTemplateChildren() + .GetTemplateDescendants() .First(x => x.Name == "PART_ContentPresenter2")); } diff --git a/tests/Avalonia.LeakTests/ControlTests.cs b/tests/Avalonia.LeakTests/ControlTests.cs index 33edc0d00d..108ba2c5f4 100644 --- a/tests/Avalonia.LeakTests/ControlTests.cs +++ b/tests/Avalonia.LeakTests/ControlTests.cs @@ -251,7 +251,7 @@ namespace Avalonia.LeakTests Assert.Same(textBox, window.Presenter!.Child); // Get the border from the TextBox template. - var border = textBox.GetTemplateChildren().FirstOrDefault(x => x.Name == "border"); + var border = textBox.GetTemplateDescendants().FirstOrDefault(x => x.Name == "border"); // The TextBox should have subscriptions to its Classes collection from the // default theme. diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_TemplatedParent.cs b/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_TemplatedParent.cs index b6cd86c563..1f2dcff0b7 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_TemplatedParent.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/Data/BindingTests_TemplatedParent.cs @@ -67,7 +67,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Data window.ApplyTemplate(); button.ApplyTemplate(); - Assert.Equal(button.Tag, button.GetTemplateChildren().OfType().First().ColumnDefinitions[0].Width); + Assert.Equal(button.Tag, button.GetTemplateDescendants().OfType().First().ColumnDefinitions[0].Width); } } } diff --git a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs index 727b3ddc45..99a79ded75 100644 --- a/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs +++ b/tests/Avalonia.Markup.Xaml.UnitTests/MarkupExtensions/CompiledBindingExtensionTests.cs @@ -1011,7 +1011,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions contentControl.DataContext = new TestDataContext(); // should be ignored contentControl.Measure(new Size(10, 10)); - var result = contentControl.GetTemplateChildren().OfType().First(); + var result = contentControl.GetTemplateDescendants().OfType().First(); Assert.Equal(false, result.Focusable); } } @@ -1046,7 +1046,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions textBox.DataContext = new TestDataContext(); // should be ignored textBox.Measure(new Size(10, 10)); - var result = textBox.GetTemplateChildren().OfType().First(); + var result = textBox.GetTemplateDescendants().OfType().First(); Assert.Equal(textBox.InnerLeftContent, result.Content); } } @@ -1080,7 +1080,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions window.ApplyTemplate(); button.ApplyTemplate(); - Assert.Equal(button.Tag, button.GetTemplateChildren().OfType().First().ColumnDefinitions[0].Width); + Assert.Equal(button.Tag, button.GetTemplateDescendants().OfType().First().ColumnDefinitions[0].Width); } } @@ -1109,7 +1109,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions var contentControl = AvaloniaRuntimeXamlLoader.Parse(xaml); contentControl.Measure(new Size(10, 10)); - var result = contentControl.GetTemplateChildren().OfType().First(); + var result = contentControl.GetTemplateDescendants().OfType().First(); Assert.Equal("Hello", result.Content); } From 28d2c288d5baab4accf3209efe2a810e5ca57ece Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Tue, 28 Apr 2026 17:54:35 +0800 Subject: [PATCH 51/60] feat: add HeaderTemplate to DrawerPage header. (#21275) --- .../Controls/DrawerPage.xaml | 34 ++++++++++--------- .../Controls/DrawerPage.xaml | 34 ++++++++++--------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/Avalonia.Themes.Fluent/Controls/DrawerPage.xaml b/src/Avalonia.Themes.Fluent/Controls/DrawerPage.xaml index 612db8d69c..e93d6c9022 100644 --- a/src/Avalonia.Themes.Fluent/Controls/DrawerPage.xaml +++ b/src/Avalonia.Themes.Fluent/Controls/DrawerPage.xaml @@ -112,14 +112,15 @@ VerticalAlignment="Center"/> - + - + - + - + Date: Tue, 28 Apr 2026 18:04:49 +0800 Subject: [PATCH 52/60] Update SkiaSharp package versions to support Bionic and fix LSX error (#21263) * Update HarfBuzzSharp and SkiaSharp package versions https://github.com/mono/SkiaSharp/releases/tag/v3.119.4-preview.1.1 SkiaSharp v3.119.4-preview.1.1 has many features: Add SkiaSharp.Views.Gtk4 using GirCore.Gtk-4.0 bindings Add Linux Bionic native assets support, that can make high-performance Android application Add PolySharp for C# 13 support on legacy TFMs Add Tizen x64 and arm64 native build support Delay-load D3D12 DLLs to prevent crashes on systems without DX12 Bump Skia milestone from 119 to 133 * Restore HarfBuzzSharp version --- Directory.Packages.props | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 7d2780e29e..942a01d13b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -48,9 +48,9 @@ - - - + + + From ea94d81609799a2af7189033ddd9da80fcd059fb Mon Sep 17 00:00:00 2001 From: Max Katz Date: Tue, 28 Apr 2026 03:17:02 -0700 Subject: [PATCH 53/60] Throw ObjectDisposedException when PlatformImpl is null in HeadlessExtension (#21276) --- .../Avalonia.Headless/HeadlessWindowExtensions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs b/src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs index 78b89d6cb1..8bb3bf4f34 100644 --- a/src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs +++ b/src/Headless/Avalonia.Headless/HeadlessWindowExtensions.cs @@ -153,7 +153,11 @@ public static class HeadlessWindowExtensions private static IHeadlessWindow GetImpl(this TopLevel topLevel) { - return topLevel.PlatformImpl as IHeadlessWindow ?? - throw new InvalidOperationException("TopLevel must be a headless window."); + return topLevel.PlatformImpl switch + { + null => throw new ObjectDisposedException(topLevel.GetType().Name), + IHeadlessWindow headless => headless, + _ => throw new InvalidOperationException("TopLevel must be a headless window.") + }; } } From 171d932b43282edeffd1255b028454bbafb72846 Mon Sep 17 00:00:00 2001 From: Shirasagi Date: Tue, 28 Apr 2026 19:57:38 +0800 Subject: [PATCH 54/60] Suppress ExecutionContext flow for render scheduling (#21273) * Add regression tests * fix executioncontext leakage * change DispatcherOperation ctor parameter to accept bool captureExecutionContext --- src/Avalonia.Base/Media/MediaContext.cs | 6 +- .../Threading/DispatcherOperation.cs | 10 ++- .../DispatcherTests.cs | 84 +++++++++++++++++++ 3 files changed, 94 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Base/Media/MediaContext.cs b/src/Avalonia.Base/Media/MediaContext.cs index d82144688d..943bf54149 100644 --- a/src/Avalonia.Base/Media/MediaContext.cs +++ b/src/Avalonia.Base/Media/MediaContext.cs @@ -91,7 +91,9 @@ internal partial class MediaContext : ICompositorScheduler if (_inputMarkerOp == null) { - _inputMarkerOp = _dispatcher.InvokeAsync(_inputMarkerHandler, DispatcherPriority.Input); + _inputMarkerOp = new DispatcherOperation(_dispatcher, DispatcherPriority.Input, _inputMarkerHandler, + throwOnUiThread: true, captureExecutionContext: false); + _dispatcher.InvokeAsyncImpl(_inputMarkerOp, CancellationToken.None); _inputMarkerAddedAt = _time.Elapsed; } else if (!now && (_time.Elapsed - _inputMarkerAddedAt).TotalSeconds > MaxSecondsWithoutInput) @@ -99,7 +101,7 @@ internal partial class MediaContext : ICompositorScheduler priority = DispatcherPriority.Input; } - var renderOp = new DispatcherOperation(_dispatcher, priority, _render, throwOnUiThread: true); + var renderOp = new DispatcherOperation(_dispatcher, priority, _render, throwOnUiThread: true, captureExecutionContext: false); _nextRenderOp = renderOp; _dispatcher.InvokeAsyncImpl(renderOp, CancellationToken.None); } diff --git a/src/Avalonia.Base/Threading/DispatcherOperation.cs b/src/Avalonia.Base/Threading/DispatcherOperation.cs index ea48fa31b0..1e19ccd196 100644 --- a/src/Avalonia.Base/Threading/DispatcherOperation.cs +++ b/src/Avalonia.Base/Threading/DispatcherOperation.cs @@ -44,18 +44,20 @@ public class DispatcherOperation private DispatcherPriority _priority; private readonly ExecutionContext? _executionContext; - internal DispatcherOperation(Dispatcher dispatcher, DispatcherPriority priority, Action callback, bool throwOnUiThread) : - this(dispatcher, priority, throwOnUiThread) + internal DispatcherOperation(Dispatcher dispatcher, DispatcherPriority priority, Action callback, bool throwOnUiThread, + bool captureExecutionContext = true) : + this(dispatcher, priority, throwOnUiThread, captureExecutionContext) { Callback = callback; } - private protected DispatcherOperation(Dispatcher dispatcher, DispatcherPriority priority, bool throwOnUiThread) + private protected DispatcherOperation(Dispatcher dispatcher, DispatcherPriority priority, bool throwOnUiThread, + bool captureExecutionContext = true) { ThrowOnUiThread = throwOnUiThread; Priority = priority; Dispatcher = dispatcher; - _executionContext = ExecutionContext.Capture(); + _executionContext = captureExecutionContext ? ExecutionContext.Capture() : null; } internal string DebugDisplay diff --git a/tests/Avalonia.Base.UnitTests/DispatcherTests.cs b/tests/Avalonia.Base.UnitTests/DispatcherTests.cs index ffb94cc5d6..2efb648f4d 100644 --- a/tests/Avalonia.Base.UnitTests/DispatcherTests.cs +++ b/tests/Avalonia.Base.UnitTests/DispatcherTests.cs @@ -6,6 +6,7 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Avalonia.Controls; using Avalonia.Controls.Platform; using Avalonia.Threading; using Avalonia.UnitTests; @@ -600,6 +601,19 @@ public partial class DispatcherTests public AsyncLocal AsyncLocalField { get; set; } = new AsyncLocal(); } + private sealed class AsyncLocalMeasureControl(Func getValue, Action setValue) : Control + { + public bool RecordMeasure { get; set; } + + protected override Size MeasureOverride(Size availableSize) + { + if (RecordMeasure) + setValue(getValue()); + + return new Size(1, 1); + } + } + [Fact] public async Task ExecutionContextIsPreservedInDispatcherInvokeAsync() { @@ -697,6 +711,76 @@ public partial class DispatcherTests Assert.Null(test); } + [Fact] + public void MediaContextRenderSchedulingDoesNotCaptureAmbientExecutionContext() + { + var impl = new SimpleDispatcherWithBackgroundProcessingImpl(); + using var services = new DispatcherServices(impl); + Dispatcher.InitializeUIThreadDispatcher(impl); + + var testObject = new AsyncLocalTestClass(); + string? test = "Not measured"; + var control = new AsyncLocalMeasureControl(() => testObject.AsyncLocalField.Value, value => test = value); + var root = new TestRoot { Child = control }; + + root.ExecuteInitialLayoutPass(); + control.RecordMeasure = true; + + Dispatcher.UIThread.Post(() => + { + testObject.AsyncLocalField.Value = "Initial Value"; + control.InvalidateMeasure(); + testObject.AsyncLocalField.Value = null; + }); + + Assert.True(impl.AskedForSignal); + impl.ExecuteSignal(); + + Assert.Null(test); + } + + [Fact] + public void MediaContextRenderSchedulingAllowsAlreadySuppressedExecutionContextFlow() + { + var impl = new SimpleDispatcherWithBackgroundProcessingImpl(); + using var services = new DispatcherServices(impl); + Dispatcher.InitializeUIThreadDispatcher(impl); + + var testObject = new AsyncLocalTestClass(); + string? test = "Not measured"; + Exception? schedulingException = null; + var control = new AsyncLocalMeasureControl(() => testObject.AsyncLocalField.Value, value => test = value); + var root = new TestRoot { Child = control }; + + root.ExecuteInitialLayoutPass(); + control.RecordMeasure = true; + + Dispatcher.UIThread.Post(() => + { + testObject.AsyncLocalField.Value = "Initial Value"; + + try + { + using (ExecutionContext.SuppressFlow()) + { + control.InvalidateMeasure(); + } + } + catch (Exception e) + { + schedulingException = e; + } + + testObject.AsyncLocalField.Value = null; + }); + + Assert.True(impl.AskedForSignal); + impl.ExecuteSignal(); + + Assert.Null(schedulingException); + Assert.Null(test); + } + [Fact] public async Task ExecutionContextCultureInfoIsPreservedInDispatcherInvokeAsync() { From 4785a10120cbf85e54a74729116081f374b44fa2 Mon Sep 17 00:00:00 2001 From: Rowe Wilson Frederisk Holme Date: Thu, 30 Apr 2026 00:54:40 +0800 Subject: [PATCH 55/60] Fix typo (#21281) --- .../webapp/modules/storage/storageItem.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Browser/Avalonia.Browser/webapp/modules/storage/storageItem.ts b/src/Browser/Avalonia.Browser/webapp/modules/storage/storageItem.ts index 2d30d1901b..0e76b93646 100644 --- a/src/Browser/Avalonia.Browser/webapp/modules/storage/storageItem.ts +++ b/src/Browser/Avalonia.Browser/webapp/modules/storage/storageItem.ts @@ -52,7 +52,7 @@ export class StorageItem { throw new Error("StorageItem is not a file"); } - await item.verityPermissions("read"); + await item.verifyPermissions("read"); const file = await (item.handle as FileSystemFileHandle).getFile(); return file; @@ -63,7 +63,7 @@ export class StorageItem { throw new Error("StorageItem is not a writeable file"); } - await item.verityPermissions("readwrite"); + await item.verifyPermissions("readwrite"); return await (item.handle as FileSystemFileHandle).createWritable({ keepExistingData: false }); } @@ -102,7 +102,7 @@ export class StorageItem { throw new TypeError("Unable to create item in the requested directory"); } - await item.verityPermissions("readwrite"); + await item.verifyPermissions("readwrite"); // The file should be truncated when it is created. const fileHandle = await ((item.handle as any).getFileHandle(name, { create: true }) as Promise); const writable = await fileHandle.createWritable({ keepExistingData: false }); @@ -115,7 +115,7 @@ export class StorageItem { return null; } - await item.verityPermissions("read"); + await item.verifyPermissions("read"); return await ((item.handle as any).getFileHandle(name) as Promise); } @@ -125,7 +125,7 @@ export class StorageItem { throw new TypeError("Unable to create item in the requested directory"); } - await item.verityPermissions("readwrite"); + await item.verifyPermissions("readwrite"); return await ((item.handle as any).getDirectoryHandle(name, { create: true }) as Promise); } @@ -135,7 +135,7 @@ export class StorageItem { return null; } - await item.verityPermissions("read"); + await item.verifyPermissions("read"); return await ((item.handle as any).getDirectoryHandle(name) as Promise); } @@ -145,7 +145,7 @@ export class StorageItem { return null; } - await item.verityPermissions("readwrite"); + await item.verifyPermissions("readwrite"); return await ((item.handle as any).remove({ recursive: true }) as Promise); } @@ -158,12 +158,12 @@ export class StorageItem { throw new TypeError("Unable to move item to the requested directory"); } - await item.verityPermissions("readwrite"); + await item.verifyPermissions("readwrite"); return await ((item.handle as any).move(destination /*, newName */) as Promise); } - private async verityPermissions(mode: "read" | "readwrite"): Promise { + private async verifyPermissions(mode: "read" | "readwrite"): Promise { if (!this.handle) { return; } From 8c3ddb105f3ac1c6129b393055fd917d944f7687 Mon Sep 17 00:00:00 2001 From: Matt <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 29 Apr 2026 20:16:49 +0300 Subject: [PATCH 56/60] Win32: Run file picker on dedicated STA thread to avoid MTA deadlock (#21266) * Run Win32 file picker on a dedicated thread to avoid MTA deadlock * Add threading comment in Win32StorageProvider --------- Co-authored-by: Julien Lebosquain --- .../Avalonia.Win32/Win32StorageProvider.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Win32StorageProvider.cs b/src/Windows/Avalonia.Win32/Win32StorageProvider.cs index a61af0de97..6519933de7 100644 --- a/src/Windows/Avalonia.Win32/Win32StorageProvider.cs +++ b/src/Windows/Avalonia.Win32/Win32StorageProvider.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.ComponentModel; using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; using Avalonia.Controls.Utils; using Avalonia.Platform.Storage; @@ -96,7 +97,13 @@ namespace Avalonia.Win32 Func convert) where TStorageItem : IStorageItem { - return Task.Factory.StartNew(() => + // TODO13: verify that we're on the correct dispatcher, matching other platforms' implementations. + // We should then be able to remove the dedicated thread and simply use IFileDialog directly (needs to be reconfirmed). + + var tcs = new TaskCompletionSource<(IReadOnlyList, int)>( + TaskCreationOptions.RunContinuationsAsynchronously); + + var thread = new Thread(() => { IReadOnlyList result = []; try @@ -179,7 +186,8 @@ namespace Avalonia.Win32 if ((uint)showResult == (uint)UnmanagedMethods.HRESULT.E_CANCELLED) { - return (result, typeIndex); + tcs.SetResult((result, typeIndex)); + return; } else if ((uint)showResult != (uint)UnmanagedMethods.HRESULT.S_OK) { @@ -210,14 +218,23 @@ namespace Avalonia.Win32 result = [convert(singleResult)]; } - return (result, typeIndex); + tcs.SetResult((result, typeIndex)); } catch (COMException ex) { var message = new Win32Exception(ex.HResult).Message; - throw new COMException(message, ex); + tcs.SetException(new COMException(message, ex)); } - }, TaskCreationOptions.LongRunning); + catch (Exception ex) + { + tcs.SetException(ex); + } + }); + thread.SetApartmentState(ApartmentState.STA); + thread.IsBackground = true; + thread.Start(); + + return tcs.Task; } private static string? GetParsingName(IShellItem shellItem) From 0c9713d9a7ae2b2aea576533e076a838ef662340 Mon Sep 17 00:00:00 2001 From: Dong Bin <14807942+rabbitism@users.noreply.github.com> Date: Thu, 30 Apr 2026 17:34:32 +0800 Subject: [PATCH 57/60] fix: update XML documentation to reflect correct type references (#21283) --- .../AutoCompleteBox.Properties.cs | 4 +-- .../AutoCompleteBox/AutoCompleteBox.cs | 20 ++++++------- src/Avalonia.Controls/Calendar/Calendar.cs | 28 +++++++++---------- .../Calendar/CalendarButton.cs | 2 +- .../Calendar/CalendarDateRange.cs | 4 +-- .../Calendar/CalendarItem.cs | 2 +- .../CalendarDatePicker/CalendarDatePicker.cs | 2 +- .../SelectingItemsControlSelectionAdapter.cs | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs index 1faa9b340e..634daa767d 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs @@ -273,10 +273,10 @@ namespace Avalonia.Controls } /// - /// Gets or sets the used + /// Gets or sets the used /// to display each item in the drop-down portion of the control. /// - /// The used to + /// The used to /// display each item in the drop-down. The default is null. /// /// You use the ItemTemplate property to specify the visualization diff --git a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs index f7f5250649..fb5c959c90 100644 --- a/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs +++ b/src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs @@ -615,11 +615,11 @@ namespace Avalonia.Controls /// /// Returns the - /// part, if + /// part, if /// possible. /// /// - /// A object, + /// A object, /// if possible. Otherwise, null. /// protected virtual ISelectionAdapter? GetSelectionAdapterPart(INameScope nameScope) @@ -681,7 +681,7 @@ namespace Avalonia.Controls /// /// Provides handling for the - /// event. + /// event. /// /// A /// that contains the event data. @@ -752,9 +752,9 @@ namespace Avalonia.Controls /// /// Provides handling for the - /// event. + /// event. /// - /// A + /// A /// that contains the event data. protected override void OnGotFocus(FocusChangedEventArgs e) { @@ -764,9 +764,9 @@ namespace Avalonia.Controls /// /// Provides handling for the - /// event. + /// event. /// - /// A + /// A /// that contains the event data. protected override void OnLostFocus(FocusChangedEventArgs e) { @@ -974,7 +974,7 @@ namespace Avalonia.Controls /// event. /// /// A - /// + /// /// that contains the event data. protected virtual void OnDropDownOpening(CancelEventArgs e) { @@ -1000,7 +1000,7 @@ namespace Avalonia.Controls /// event. /// /// A - /// + /// /// that contains the event data. protected virtual void OnDropDownClosing(CancelEventArgs e) { @@ -1559,7 +1559,7 @@ namespace Avalonia.Controls /// /// Notifies the /// that the - /// + /// /// property has been set and the data can be filtered to provide /// possible matches in the drop-down. /// diff --git a/src/Avalonia.Controls/Calendar/Calendar.cs b/src/Avalonia.Controls/Calendar/Calendar.cs index dc8ea002d9..819019a634 100644 --- a/src/Avalonia.Controls/Calendar/Calendar.cs +++ b/src/Avalonia.Controls/Calendar/Calendar.cs @@ -363,7 +363,7 @@ namespace Avalonia.Controls /// /// /// A value indicating what length of time the - /// should display. + /// should display. /// public CalendarMode DisplayMode { @@ -450,7 +450,7 @@ namespace Avalonia.Controls /// /// /// A value that indicates the current selection mode. The default is - /// . + /// . /// /// /// @@ -537,18 +537,18 @@ namespace Avalonia.Controls /// The date currently selected. The default is null. /// /// The given date is outside the range specified by - /// - /// and + /// + /// and /// -or- /// The given date is in the - /// + /// /// collection. /// /// /// If set to anything other than null when - /// is + /// is /// set to - /// . + /// . /// /// /// Use this property when SelectionMode is set to SingleDate. In other @@ -615,7 +615,7 @@ namespace Avalonia.Controls /// Gets a collection of selected dates. /// /// - /// A + /// A /// object that contains the currently selected dates. The default is an /// empty collection. /// @@ -763,9 +763,9 @@ namespace Avalonia.Controls /// The date to display. /// /// The given date is not in the range specified by - /// + /// /// and - /// . + /// . /// /// /// @@ -1446,7 +1446,7 @@ namespace Avalonia.Controls /// /// Occurs when the - /// + /// /// property is changed. /// /// @@ -1456,7 +1456,7 @@ namespace Avalonia.Controls /// /// Occurs when the - /// + /// /// property is changed. /// public event EventHandler? DisplayModeChanged; @@ -2214,7 +2214,7 @@ namespace Avalonia.Controls /// /// Initializes a new instance of the - /// class. + /// class. /// public Calendar() { @@ -2230,7 +2230,7 @@ namespace Avalonia.Controls /// /// Builds the visual tree for the - /// when a new + /// when a new /// template is applied. /// protected override void OnApplyTemplate(TemplateAppliedEventArgs e) diff --git a/src/Avalonia.Controls/Calendar/CalendarButton.cs b/src/Avalonia.Controls/Calendar/CalendarButton.cs index 6bc704888e..d4cb17a997 100644 --- a/src/Avalonia.Controls/Calendar/CalendarButton.cs +++ b/src/Avalonia.Controls/Calendar/CalendarButton.cs @@ -97,7 +97,7 @@ namespace Avalonia.Controls.Primitives /// /// Builds the visual tree for the - /// + /// /// when a new template is applied. /// protected override void OnApplyTemplate(TemplateAppliedEventArgs e) diff --git a/src/Avalonia.Controls/Calendar/CalendarDateRange.cs b/src/Avalonia.Controls/Calendar/CalendarDateRange.cs index 793ef7a2ee..826886efb8 100644 --- a/src/Avalonia.Controls/Calendar/CalendarDateRange.cs +++ b/src/Avalonia.Controls/Calendar/CalendarDateRange.cs @@ -23,7 +23,7 @@ namespace Avalonia.Controls /// /// Initializes a new instance of the - /// class + /// class /// with a single date. /// /// The date to be represented by the range. @@ -35,7 +35,7 @@ namespace Avalonia.Controls /// /// Initializes a new instance of the - /// class + /// class /// with a range of dates. /// /// diff --git a/src/Avalonia.Controls/Calendar/CalendarItem.cs b/src/Avalonia.Controls/Calendar/CalendarItem.cs index 3d548e15b9..e33298023f 100644 --- a/src/Avalonia.Controls/Calendar/CalendarItem.cs +++ b/src/Avalonia.Controls/Calendar/CalendarItem.cs @@ -244,7 +244,7 @@ namespace Avalonia.Controls.Primitives /// /// Builds the visual tree for the - /// + /// /// when a new template is applied. /// protected override void OnApplyTemplate(TemplateAppliedEventArgs e) diff --git a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs index 6a3f44aa5f..097fd2fb85 100644 --- a/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs +++ b/src/Avalonia.Controls/CalendarDatePicker/CalendarDatePicker.cs @@ -64,7 +64,7 @@ namespace Avalonia.Controls public event EventHandler? CalendarOpened; /// - /// Occurs when + /// Occurs when /// is assigned a value that cannot be interpreted as a date. /// public event EventHandler? DateValidationError; diff --git a/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs b/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs index bdb6dad5d3..127925865c 100644 --- a/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs +++ b/src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs @@ -91,7 +91,7 @@ namespace Avalonia.Controls.Utils /// /// Initializes a new instance of the - /// + /// /// class with the specified /// /// control. From 550b57db3340857f1ddd883f7a71ea95c4faceac Mon Sep 17 00:00:00 2001 From: Diego Rivero <7670773+dirivero@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:04:13 -0300 Subject: [PATCH 58/60] Fix DeviceLuid byte ordering on MacOS GPU interop (#21293) bytes.Reverse() was resolving to System.Linq.Enumberable.Reverse(). Forcing now to MemoryExtensions.Reverse(Span) by calling AsSpan(). --- src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs | 2 +- src/Avalonia.Native/Metal.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs b/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs index 9efe33689f..7e111735cf 100644 --- a/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs +++ b/src/Avalonia.Native/AvaloniaNativeGlPlatformGraphics.cs @@ -264,7 +264,7 @@ namespace Avalonia.Native { // We are reversing bytes to match MoltenVK (LUID is a Vulkan term after all) var bytes = BitConverter.GetBytes(registryId); - bytes.Reverse(); + bytes.AsSpan().Reverse(); DeviceLuid = bytes; } } diff --git a/src/Avalonia.Native/Metal.cs b/src/Avalonia.Native/Metal.cs index 3137ce1b6b..fba317cc53 100644 --- a/src/Avalonia.Native/Metal.cs +++ b/src/Avalonia.Native/Metal.cs @@ -102,7 +102,7 @@ internal class MetalExternalObjectsFeature : IMetalExternalObjectsFeature if (_device.GetIOKitRegistryId(®istryId) != 0) { var bytes = BitConverter.GetBytes(registryId); - bytes.Reverse(); + bytes.AsSpan().Reverse(); DeviceLuid = bytes; } } From 1365b64d9158248f071a8c8c43313101590d8979 Mon Sep 17 00:00:00 2001 From: Tom Edwards <109803929+TomEdwardsEnscape@users.noreply.github.com> Date: Mon, 4 May 2026 11:16:43 +0200 Subject: [PATCH 59/60] Avoid exceptions when getting position from a PointerEventArgs (#21301) Return null when an IPresentationSource can't convert from/to screen coordinates Document exceptions in VisualExtensions PointToClient and PointToScreen Add tests for cross-root pointer event positions --- src/Avalonia.Base/Input/PointerEventArgs.cs | 40 ++++++----- .../Rendering/IPresentationSource.cs | 4 +- src/Avalonia.Base/VisualExtensions.cs | 10 +-- .../PresentationSource.RenderRoot.cs | 4 +- .../Input/MouseDeviceTests.cs | 72 ++++++++++++++++++- tests/Avalonia.RenderTests/TestRenderRoot.cs | 4 +- tests/Avalonia.UnitTests/TestRoot.cs | 4 +- 7 files changed, 106 insertions(+), 32 deletions(-) diff --git a/src/Avalonia.Base/Input/PointerEventArgs.cs b/src/Avalonia.Base/Input/PointerEventArgs.cs index 9285e65fa5..ee1b54b792 100644 --- a/src/Avalonia.Base/Input/PointerEventArgs.cs +++ b/src/Avalonia.Base/Input/PointerEventArgs.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using Avalonia.Input.Raw; using Avalonia.Interactivity; using Avalonia.Metadata; -using Avalonia.VisualTree; +using Avalonia.Rendering; namespace Avalonia.Input { public class PointerEventArgs : RoutedEventArgs, IKeyModifiersEventArgs { - private readonly Visual? _rootVisual; - private readonly Point _rootVisualPosition; + private readonly IPresentationSource? _eventPresentationSource; // the original observer of the event + private readonly Point _presentationSourcePosition; private readonly PointerPointProperties _properties; private readonly Lazy?>? _previousPoints; @@ -24,8 +24,8 @@ namespace Avalonia.Input : base(routedEvent) { Source = source; - _rootVisual = rootVisual; - _rootVisualPosition = rootVisualPosition; + _eventPresentationSource = rootVisual?.PresentationSource; + _presentationSourcePosition = rootVisualPosition; _properties = properties; Pointer = pointer; Timestamp = timestamp; @@ -76,23 +76,25 @@ namespace Avalonia.Input private Point GetPosition(Point pt, Visual? relativeTo) { - if (_rootVisual == null) - return default; if (relativeTo == null) return pt; + if (_eventPresentationSource == null || relativeTo?.PresentationSource?.RootVisual == null) + return default; - // If the visual the user passed in, is not connected to the same visual root - // (i.e. they called it for a control inside a popup. - if (!ReferenceEquals(_rootVisual, relativeTo.VisualRoot) && relativeTo.VisualRoot is { }) + if (relativeTo.PresentationSource != _eventPresentationSource) { - // Convert to absolute screen coordinates. - var screenPt = _rootVisual.PointToScreen(pt); - - // Convert to client co-ordinates of the visual inside the other visual root. - return relativeTo.PointToClient(screenPt); + if (_eventPresentationSource.PointToScreen(pt) is { } screenPt && + relativeTo.PresentationSource.PointToClient(screenPt) is { } targetClientPt) + { + pt = targetClientPt; + } + else + { + return default; + } } - return pt * _rootVisual.TransformToVisual(relativeTo) ?? default; + return relativeTo.PresentationSource.RootVisual.TranslatePoint(pt, relativeTo) ?? default; } /// @@ -100,7 +102,7 @@ namespace Avalonia.Input /// /// The visual whose coordinate system to use. Pass null for toplevel coordinate system /// The pointer position in the control's coordinates. - public Point GetPosition(Visual? relativeTo) => GetPosition(_rootVisualPosition, relativeTo); + public Point GetPosition(Visual? relativeTo) => GetPosition(_presentationSourcePosition, relativeTo); /// /// Returns the PointerPoint associated with the current event @@ -117,7 +119,7 @@ namespace Avalonia.Input /// public IReadOnlyList GetIntermediatePoints(Visual? relativeTo) { - var previousPoints = _previousPoints?.Value; + var previousPoints = _previousPoints?.Value; if (previousPoints == null || previousPoints.Count == 0) return new[] { GetCurrentPoint(relativeTo) }; var points = new PointerPoint[previousPoints.Count + 1]; @@ -145,7 +147,7 @@ namespace Avalonia.Input /// public PointerPointProperties Properties => _properties; } - + public enum MouseButton { None, diff --git a/src/Avalonia.Base/Rendering/IPresentationSource.cs b/src/Avalonia.Base/Rendering/IPresentationSource.cs index bf5beebe49..ff9da11afa 100644 --- a/src/Avalonia.Base/Rendering/IPresentationSource.cs +++ b/src/Avalonia.Base/Rendering/IPresentationSource.cs @@ -41,6 +41,6 @@ public interface IPresentationSource /// internal Size ClientSize { get; } - internal PixelPoint PointToScreen(Point point); - internal Point PointToClient(PixelPoint point); + internal PixelPoint? PointToScreen(Point point); + internal Point? PointToClient(PixelPoint point); } diff --git a/src/Avalonia.Base/VisualExtensions.cs b/src/Avalonia.Base/VisualExtensions.cs index 3df2eca039..fa4236bf46 100644 --- a/src/Avalonia.Base/VisualExtensions.cs +++ b/src/Avalonia.Base/VisualExtensions.cs @@ -14,12 +14,13 @@ namespace Avalonia /// The visual. /// The point in screen coordinates. /// The point in client coordinates. + /// Thown when does not belong to a visual tree. public static Point PointToClient(this Visual visual, PixelPoint point) { var source = visual.PresentationSource; var root = source?.RootVisual ?? - throw new ArgumentException("Control does not belong to a visual tree.", nameof(visual)); - var rootPoint = source.PointToClient(point); + throw new ArgumentException("Visual does not belong to a visual tree.", nameof(visual)); + var rootPoint = source.PointToClient(point) ?? default; return root.TranslatePoint(rootPoint, visual)!.Value; } @@ -29,13 +30,14 @@ namespace Avalonia /// The visual. /// The point in client coordinates. /// The point in screen coordinates. + /// Thown when does not belong to a visual tree. public static PixelPoint PointToScreen(this Visual visual, Point point) { var source = visual.PresentationSource; var root = source?.RootVisual ?? - throw new ArgumentException("Control does not belong to a visual tree.", nameof(visual)); + throw new ArgumentException("Visual does not belong to a visual tree.", nameof(visual)); var p = visual.TranslatePoint(point, root); - return source.PointToScreen(p!.Value); + return source.PointToScreen(p!.Value) ?? default; } /// diff --git a/src/Avalonia.Controls/PresentationSource/PresentationSource.RenderRoot.cs b/src/Avalonia.Controls/PresentationSource/PresentationSource.RenderRoot.cs index 2a9e833a48..e5fb12eba4 100644 --- a/src/Avalonia.Controls/PresentationSource/PresentationSource.RenderRoot.cs +++ b/src/Avalonia.Controls/PresentationSource/PresentationSource.RenderRoot.cs @@ -23,9 +23,9 @@ internal partial class PresentationSource _pointerOverPreProcessor?.SceneInvalidated(sceneInvalidatedEventArgs.DirtyRect); } - public PixelPoint PointToScreen(Point point) => PlatformImpl?.PointToScreen(point) ?? default; + public PixelPoint? PointToScreen(Point point) => PlatformImpl?.PointToScreen(point); - public Point PointToClient(PixelPoint point) => PlatformImpl?.PointToClient(point) ?? default; + public Point? PointToClient(PixelPoint point) => PlatformImpl?.PointToClient(point); private void HandleScalingChanged(double scaling) => RenderScaling = LayoutHelper.ValidateScaling(scaling); diff --git a/tests/Avalonia.Base.UnitTests/Input/MouseDeviceTests.cs b/tests/Avalonia.Base.UnitTests/Input/MouseDeviceTests.cs index 1ec6ec2be5..f8bb8c3ed2 100644 --- a/tests/Avalonia.Base.UnitTests/Input/MouseDeviceTests.cs +++ b/tests/Avalonia.Base.UnitTests/Input/MouseDeviceTests.cs @@ -1,4 +1,6 @@ -using Avalonia.Controls; +using System; +using Avalonia.Controls; +using Avalonia.Headless; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Media; @@ -128,6 +130,74 @@ namespace Avalonia.Base.UnitTests.Input Assert.Equal(new Point(1, 11), result); } + private IDisposable SetupCrossTreePositionRequest(PixelPoint topLevelPosition, out PointerEventArgs pointerEvent, out Control elementA, out Control elementB) + { + var app = UnitTestApplication.Start(new TestServices( + inputManager: new InputManager(), + renderInterface: new HeadlessPlatformRenderInterface())); + + var renderer = new Mock(); + var deviceMock = CreatePointerDeviceMock(); + var impl1 = CreateTopLevelImplMock(); + // Mocked position: topLevelPosition + impl1.Setup(w => w.PointToScreen(default)).Returns(p => (PixelPoint.FromPoint(p, 1) + topLevelPosition)); + + elementA = new Border(); + PointerEventArgs? moveEventArgs = null; + + elementA.PointerMoved += (s, e) => moveEventArgs = e; + var root1 = CreateInputRoot(impl1.Object, elementA, renderer.Object); + + SetMove(deviceMock, root1.InputRoot, elementA); + impl1.Object.Input!(CreateRawPointerMovedArgs(deviceMock.Object, root1)); + + Assert.NotNull(moveEventArgs); + pointerEvent = moveEventArgs; + + var impl2 = CreateTopLevelImplMock(); + // Mocked position: topLevelPosition * 2 + impl2.Setup(w => w.PointToClient(default)).Returns(p => (p - topLevelPosition - topLevelPosition).ToPoint(1)); + + elementB = new Border(); + var root2 = CreateInputRoot(impl2.Object, elementB, renderer.Object); + + return app; + } + + [Fact] + public void GetPosition_Should_Support_Cross_Tree_Requests() + { + var topLevelOffset = new PixelPoint(5, 0); + using (SetupCrossTreePositionRequest(topLevelOffset, out var pointerEvent, out _, out var elementB)) + { + Assert.Equal(topLevelOffset.ToPoint(1), pointerEvent.GetPosition(elementB)); + } + } + + [Fact] + public void GetPosition_Should_Return_Default_When_Cross_Tree_Source_Closed() + { + var topLevelOffset = new PixelPoint(5, 0); + using (SetupCrossTreePositionRequest(topLevelOffset, out var pointerEvent, out var elementA, out var elementB)) + { + ((PresentationSource)elementA.PresentationSource!).Dispose(); + + Assert.Equal(default, pointerEvent.GetPosition(elementB)); + } + } + + [Fact] + public void GetPosition_Should_Return_Default_When_Cross_Tree_Target_Closed() + { + var topLevelOffset = new PixelPoint(5, 0); + using (SetupCrossTreePositionRequest(topLevelOffset, out var pointerEvent, out _, out var elementB)) + { + ((PresentationSource)elementB.PresentationSource!).Dispose(); + + Assert.Equal(default, pointerEvent.GetPosition(elementB)); + } + } + [Fact] public void Mouse_Pointer_Should_Set_Focus_On_Pointer_Pressed() { diff --git a/tests/Avalonia.RenderTests/TestRenderRoot.cs b/tests/Avalonia.RenderTests/TestRenderRoot.cs index 602c5c6e8b..4bbe560fb6 100644 --- a/tests/Avalonia.RenderTests/TestRenderRoot.cs +++ b/tests/Avalonia.RenderTests/TestRenderRoot.cs @@ -67,9 +67,9 @@ namespace Avalonia.Skia.RenderTests { } - public Point PointToClient(PixelPoint point) => point.ToPoint(RenderScaling); + public Point? PointToClient(PixelPoint point) => point.ToPoint(RenderScaling); - public PixelPoint PointToScreen(Point point) => PixelPoint.FromPoint(point, RenderScaling); + public PixelPoint? PointToScreen(Point point) => PixelPoint.FromPoint(point, RenderScaling); public IFocusManager? FocusManager { get; } public IPlatformSettings? PlatformSettings { get; } diff --git a/tests/Avalonia.UnitTests/TestRoot.cs b/tests/Avalonia.UnitTests/TestRoot.cs index 4400d77267..5a34d301df 100644 --- a/tests/Avalonia.UnitTests/TestRoot.cs +++ b/tests/Avalonia.UnitTests/TestRoot.cs @@ -113,9 +113,9 @@ namespace Avalonia.UnitTests { } - public Point PointToClient(PixelPoint p) => p.ToPoint(1); + public Point? PointToClient(PixelPoint p) => p.ToPoint(1); - public PixelPoint PointToScreen(Point p) => PixelPoint.FromPoint(p, 1); + public PixelPoint? PointToScreen(Point p) => PixelPoint.FromPoint(p, 1); public void RegisterChildrenNames() From dcb607179b707a6c0e41a39fc697af43c00abc48 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Mon, 4 May 2026 12:25:57 +0000 Subject: [PATCH 60/60] fix android file props (#21307) --- .../Platform/Storage/AndroidStorageItem.cs | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Android/Avalonia.Android/Platform/Storage/AndroidStorageItem.cs b/src/Android/Avalonia.Android/Platform/Storage/AndroidStorageItem.cs index 2ee0236828..a5ceb02312 100644 --- a/src/Android/Avalonia.Android/Platform/Storage/AndroidStorageItem.cs +++ b/src/Android/Avalonia.Android/Platform/Storage/AndroidStorageItem.cs @@ -546,8 +546,7 @@ internal sealed class AndroidStorageFile : AndroidStorageItem, IStorageBookmarkF { var projection = new[] { - MediaStore.IMediaColumns.Size, MediaStore.IMediaColumns.DateAdded, - MediaStore.IMediaColumns.DateModified + Document.ColumnSize, Document.ColumnLastModified }; using var cursor = Activity.ContentResolver!.Query(Uri, projection, null, null, null); @@ -555,7 +554,7 @@ internal sealed class AndroidStorageFile : AndroidStorageItem, IStorageBookmarkF { try { - var columnIndex = cursor.GetColumnIndex(MediaStore.IMediaColumns.Size); + var columnIndex = cursor.GetColumnIndex(Document.ColumnSize); if (columnIndex != -1) { size = (ulong)cursor.GetLong(columnIndex); @@ -569,22 +568,7 @@ internal sealed class AndroidStorageFile : AndroidStorageItem, IStorageBookmarkF try { - var columnIndex = cursor.GetColumnIndex(MediaStore.IMediaColumns.DateAdded); - if (columnIndex != -1) - { - var longValue = cursor.GetLong(columnIndex); - itemDate = longValue > 0 ? DateTimeOffset.FromUnixTimeMilliseconds(longValue) : null; - } - } - catch (Exception ex) - { - Logger.TryGet(LogEventLevel.Verbose, LogArea.AndroidPlatform)? - .Log(this, "File DateAdded metadata reader failed: '{Exception}'", ex); - } - - try - { - var columnIndex = cursor.GetColumnIndex(MediaStore.IMediaColumns.DateModified); + var columnIndex = cursor.GetColumnIndex(Document.ColumnLastModified); if (columnIndex != -1) { var longValue = cursor.GetLong(columnIndex); @@ -594,7 +578,7 @@ internal sealed class AndroidStorageFile : AndroidStorageItem, IStorageBookmarkF catch (Exception ex) { Logger.TryGet(LogEventLevel.Verbose, LogArea.AndroidPlatform)? - .Log(this, "File DateAdded metadata reader failed: '{Exception}'", ex); + .Log(this, "File LastModified metadata reader failed: '{Exception}'", ex); } } }