From d19502b0753842fc8d1070563d56b63b38c4ecb5 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 5 Feb 2023 17:39:28 -0500 Subject: [PATCH 1/2] Samples - Fixed v11-prev5 breaking change of empty/transparent window caused by unspecified theme --- Prism.Avalonia.sln | 2 +- Upgrading-to-Avalonia-11.md | 1 + samples/BootstrapperShellSample/App.axaml | 4 +++- samples/ModulesSample/App.axaml | 4 +++- .../{ModulesSample.csproj => ModulesSampleApp.csproj} | 0 5 files changed, 8 insertions(+), 3 deletions(-) rename samples/ModulesSample/{ModulesSample.csproj => ModulesSampleApp.csproj} (100%) diff --git a/Prism.Avalonia.sln b/Prism.Avalonia.sln index 7737bf5..9458591 100644 --- a/Prism.Avalonia.sln +++ b/Prism.Avalonia.sln @@ -20,7 +20,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ViewDiscovery", "samples\Vi EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DummyModules", "DummyModules", "{E03DB670-BFA9-4E7B-A69C-D1E6B8E1691F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModulesSample", "samples\ModulesSample\ModulesSample.csproj", "{DCC68F88-29C9-44EF-90E3-685666AFD6AD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModulesSampleApp", "samples\ModulesSample\ModulesSampleApp.csproj", "{DCC68F88-29C9-44EF-90E3-685666AFD6AD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DummyModule1", "samples\DummyModule1\DummyModule1.csproj", "{2B315287-FDAE-4092-9A80-7DA07D934BF1}" EndProject diff --git a/Upgrading-to-Avalonia-11.md b/Upgrading-to-Avalonia-11.md index 250bc09..bf2a738 100644 --- a/Upgrading-to-Avalonia-11.md +++ b/Upgrading-to-Avalonia-11.md @@ -26,6 +26,7 @@ Check out Avalonia's [Breaking Changes](https://github.com/AvaloniaUI/Avalonia/w * The case was for "_single view platforms_" and not just Desktops which have a `Window` object. * Themes: * Themes must be download as part of a separate package and `App.axaml` implementation has changed. + * User MUST set a theme in `App.axaml`, otherwise the window's contents may be transparent * See, [PR# 8148](https://github.com/AvaloniaUI/Avalonia/pull/8166), [PR #8166](https://github.com/AvaloniaUI/Avalonia/pull/8166), [Issue #5593](https://github.com/AvaloniaUI/Avalonia/issues/5593) * NEW: `` * OLD: `` diff --git a/samples/BootstrapperShellSample/App.axaml b/samples/BootstrapperShellSample/App.axaml index 315ab9d..4f29664 100644 --- a/samples/BootstrapperShellSample/App.axaml +++ b/samples/BootstrapperShellSample/App.axaml @@ -1,7 +1,9 @@  + x:Class="BootstrapperShellSample.App" + RequestedThemeVariant="Light"> + diff --git a/samples/ModulesSample/App.axaml b/samples/ModulesSample/App.axaml index b2f5e3b..17fad1e 100644 --- a/samples/ModulesSample/App.axaml +++ b/samples/ModulesSample/App.axaml @@ -1,7 +1,9 @@  + x:Class="ModulesSample.App" + RequestedThemeVariant="Light"> + diff --git a/samples/ModulesSample/ModulesSample.csproj b/samples/ModulesSample/ModulesSampleApp.csproj similarity index 100% rename from samples/ModulesSample/ModulesSample.csproj rename to samples/ModulesSample/ModulesSampleApp.csproj From 9b3b7a57a6a75dcf108d3e1fadd1b85294d25073 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Sun, 5 Feb 2023 19:28:11 -0500 Subject: [PATCH 2/2] SampleMvvmApp - Added theme switcher example to DashboardView --- samples/ModulesSample/App.axaml.cs | 2 -- .../ViewModels/DashboardViewModel.cs | 29 +++++++++++++++++-- .../SampleMvvmApp/Views/DashboardView.axaml | 12 ++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/samples/ModulesSample/App.axaml.cs b/samples/ModulesSample/App.axaml.cs index ec800a4..f4c3c5c 100644 --- a/samples/ModulesSample/App.axaml.cs +++ b/samples/ModulesSample/App.axaml.cs @@ -13,8 +13,6 @@ using System.Threading; using Avalonia.Dialogs; using ModulesSample.Infrastructure; -using static System.Net.WebRequestMethods; -using System.Security.Policy; namespace ModulesSample { diff --git a/samples/SampleMvvmApp/ViewModels/DashboardViewModel.cs b/samples/SampleMvvmApp/ViewModels/DashboardViewModel.cs index 36de9ea..a89e2f3 100644 --- a/samples/SampleMvvmApp/ViewModels/DashboardViewModel.cs +++ b/samples/SampleMvvmApp/ViewModels/DashboardViewModel.cs @@ -1,6 +1,8 @@ -using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Avalonia; +using Avalonia.Styling; using Prism.Commands; -using Prism.Regions; using SampleMvvmApp.Services; namespace SampleMvvmApp.ViewModels @@ -12,10 +14,14 @@ public class DashboardViewModel : ViewModelBase private int _listItemSelected = -1; private ObservableCollection _listItems = new(); private string _listItemText; + private ThemeVariant _themeSelected; + private int _themeSelectedIndex = 0; - public DashboardViewModel(IRegionManager regionManager, INotificationService notifyService) + public DashboardViewModel(INotificationService notifyService) { _notification = notifyService; + + ThemeSelected = Application.Current!.RequestedThemeVariant; } public DelegateCommand CmdAddItem => new(() => @@ -68,5 +74,22 @@ public ObservableCollection ListItems get => _listItems; set => SetProperty(ref _listItems, value); } + + public ThemeVariant ThemeSelected + { + get => _themeSelected; + set + { + SetProperty(ref _themeSelected, value); + Application.Current!.RequestedThemeVariant = _themeSelected; + } + } + + public List ThemeStyles => new() + { + ThemeVariant.Default, + ThemeVariant.Dark, + ThemeVariant.Light, + }; } } diff --git a/samples/SampleMvvmApp/Views/DashboardView.axaml b/samples/SampleMvvmApp/Views/DashboardView.axaml index 2f6c950..6abda6b 100644 --- a/samples/SampleMvvmApp/Views/DashboardView.axaml +++ b/samples/SampleMvvmApp/Views/DashboardView.axaml @@ -27,6 +27,18 @@