diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..4790edf --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,12 @@ +{ + "default": true, + "no-hard-tabs": true, + "MD007": { "indent": 2 }, + "MD013": false, + "MD024": { "siblings_only": true, "allow_different_nesting": true }, + "MD033": { + "allowed_elements": [ "br", "hr" ] + }, + "MD055": false, + "MD056": false +} \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..bad5a62 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,13 @@ + + + en + true + + + + + true + $(NoWarn);NU5104;NU5100;NU5118;NU5123;NU1603;CS1701;CS1702;XA0101;MSB3277;CS8785;CS8669;CS1998;NU1507 + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..8c119d5 --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,2 @@ + + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..e1b0af5 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Prism.Avalonia.sln b/Prism.Avalonia.sln index ee611f5..b12029f 100644 --- a/Prism.Avalonia.sln +++ b/Prism.Avalonia.sln @@ -35,6 +35,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A1A058C5 build\AvaloniaDependency.props = build\AvaloniaDependency.props build\Base.props = build\Base.props build\BuildTargets.props = build\BuildTargets.props + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + Directory.Packages.props = Directory.Packages.props build\EmbedXaml.props = build\EmbedXaml.props build\Library.props = build\Library.props build\Nuget.props = build\Nuget.props @@ -44,16 +47,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A1A058C5 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Avalonia", "Avalonia", "{9FF880E7-B56A-4E8E-9226-90A928FDE3AB}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Containers", "Containers", "{366415D3-E0ED-449C-99E2-A258F6A566F6}" -EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.DryIoc.Shared", "src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.shproj", "{6E7EC81D-DA39-4C4F-A898-0148558C34F4}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleMvvmApp", "e2e\SampleMvvmApp\SampleMvvmApp.csproj", "{7AF14280-214B-4A96-AFE8-CF063E2B6CA4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{966DDDE9-D31A-404B-9F24-5378DE8A12C8}" EndProject -Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Prism.Container.Avalonia.Shared", "tests\Avalonia\Prism.Container.Avalonia.Shared\Prism.Container.Avalonia.Shared.shproj", "{340538B6-0781-470E-8BD1-7B7735FDC554}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prism.Avalonia.Tests", "tests\Avalonia\Prism.Avalonia.Tests\Prism.Avalonia.Tests.csproj", "{DAFC499B-E379-4453-BDCE-2EC30E1290C8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleDialogApp", "e2e\SampleDialogApp\SampleDialogApp.csproj", "{97F8C6D3-308C-40BD-B181-5CDFCF101CBF}" @@ -135,19 +132,11 @@ Global {47BC0E69-AF2D-4C4F-886E-31B61E05C57A} = {5F8D330E-F611-4E17-8217-F2D6CDB8E1F7} {B7112DF9-D7A1-48B8-8821-CF81D52F793E} = {47BC0E69-AF2D-4C4F-886E-31B61E05C57A} {9FF880E7-B56A-4E8E-9226-90A928FDE3AB} = {70B9D432-E8BD-4EB9-9CA8-E63E2C804F3F} - {366415D3-E0ED-449C-99E2-A258F6A566F6} = {70B9D432-E8BD-4EB9-9CA8-E63E2C804F3F} - {6E7EC81D-DA39-4C4F-A898-0148558C34F4} = {366415D3-E0ED-449C-99E2-A258F6A566F6} {7AF14280-214B-4A96-AFE8-CF063E2B6CA4} = {5F8D330E-F611-4E17-8217-F2D6CDB8E1F7} - {340538B6-0781-470E-8BD1-7B7735FDC554} = {966DDDE9-D31A-404B-9F24-5378DE8A12C8} {DAFC499B-E379-4453-BDCE-2EC30E1290C8} = {966DDDE9-D31A-404B-9F24-5378DE8A12C8} {97F8C6D3-308C-40BD-B181-5CDFCF101CBF} = {5F8D330E-F611-4E17-8217-F2D6CDB8E1F7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D260344D-8648-441D-B85B-9D280005F098} EndGlobalSection - GlobalSection(SharedMSBuildProjectFiles) = preSolution - tests\Avalonia\Prism.Container.Avalonia.Shared\Prism.Container.Avalonia.Shared.projitems*{340538b6-0781-470e-8bd1-7b7735fdc554}*SharedItemsImports = 13 - src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{6e7ec81d-da39-4c4f-a898-0148558c34f4}*SharedItemsImports = 13 - src\Containers\Prism.DryIoc.Shared\Prism.DryIoc.Shared.projitems*{a379e2c8-bd9a-42a1-8218-ced3c0d75e64}*SharedItemsImports = 5 - EndGlobalSection EndGlobal diff --git a/PrismLibrary_Avalonia.slnf b/PrismLibrary_Avalonia.slnf new file mode 100644 index 0000000..3f4b24d --- /dev/null +++ b/PrismLibrary_Avalonia.slnf @@ -0,0 +1,14 @@ +{ + "solution": { + "path": "Prism.Avalonia.sln", + "projects": [ + "src\\Containers\\Prism.DryIoc.Shared\\Prism.DryIoc.Shared.shproj", + "src\\Prism.Avalonia\\Prism.Avalonia.csproj", + "src\\Prism.DryIoc.Avalonia\\Prism.DryIoc.Avalonia.csproj", + "tests\\Avalonia\\Prism.Avalonia.Tests\\Prism.Avalonia.Tests.csproj", + "tests\\Avalonia\\Prism.Container.Avalonia.Shared\\Prism.Container.Avalonia.Shared.shproj", + "tests\\Avalonia\\Prism.DryIoc.Avalonia.Tests\\Prism.DryIoc.Avalonia.Tests.csproj", + "tests\\Avalonia\\Prism.IocContainer.Avalonia.Tests.Support\\Prism.IocContainer.Avalonia.Tests.Support.csproj" + ] + } +} \ No newline at end of file diff --git a/Upgrade-Prism-8.1-9.x.md b/Upgrade-Prism-8.1-9.x.md deleted file mode 100644 index f7bcc90..0000000 --- a/Upgrade-Prism-8.1-9.x.md +++ /dev/null @@ -1,9 +0,0 @@ -# Upgrading Prism.Avalonia to v9.0-pre - -## Overview - -This file documents the upgrade path from Prism v8.1.97 to v9.0-pre support. Soon we will be moving this repo to be apart of the main Prism Library `:)` - -## Changes - -* `Samples` folder renamed to `e2e` diff --git a/Upgrade-Prism-7.2-to-8.1.md b/Upgrading-Prism.md similarity index 85% rename from Upgrade-Prism-7.2-to-8.1.md rename to Upgrading-Prism.md index 3f43097..b0bacb9 100644 --- a/Upgrade-Prism-7.2-to-8.1.md +++ b/Upgrading-Prism.md @@ -1,4 +1,6 @@ -# Upgrading from Prism 7.2 to 8.1 +# Upgrading Prism.Avalonia + +This file documents the upgrade path of the Prism releases, noting files removed :x: , added :new:, and notes on breaking changes. | Icon | Text | Description | |------|------|-------------| @@ -10,9 +12,121 @@ | 💔 | `:broken_heart:` | Never implemented in this platform * [Icon Reference](https://github.com/markdown-templates/markdown-emojis) + +## Overview Prism 8.1.97 to 9.0.x + +This file documents the upgrade path from Prism v8.1.97 to v9.0-pre support. Soon we will be moving this repo to be apart of the main Prism Library `:)` + +Each of the following will be tagged and merged into the branch `Prism-9x` before being merged with `develop` and `master` branches. + +**Progress:** + +* [/] 9.0.271-pre - Will be tagged and released +* [ ] 9.0.401-pre - Will be tagged and released + +### Release Comparison + +As we all know, not everything is straight forward between these two XAML technologies. However, it's a good reminder to document the differences and 'got-yas'. + +* [Prism v7.2.0.1422 to v8.0.0.1909](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.0.0.1909) +* [Prism v7.2.0.1422 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) +* [Prism v8.0.0.1909 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v8.0.0.1909...v8.1.97) +* [DNF - 9.0.264-pre](https://github.com/PrismLibrary/Prism/compare/DNF...9.0.264-pre) - (_DNF = Dot Net Foundation_) +* [9.0.264-pre - 9.0.274-pre](https://github.com/PrismLibrary/Prism/compare/9.0.264-pre...9.0.271-pre) +* [9.0.274-pre - 9.0.401-pre](https://github.com/PrismLibrary/Prism/compare/9.0.271-pre...9.0.401-pre) + +### Changes + +* `Samples` folder renamed to `e2e` +* Prism.Dialogs + * _Various updates, see section before for more info_ +* `NavigationResult` returns the property `Success` instead of `Result` + +#### Dialogs + +**Breaking Changes:** + +* ***UPGRADE SAMPLE NEEDED*** +* Namespace changed from `Prism.Services.Dialogs` to `Prism.Dialogs`. +* `IDialogAware` property, `RequestClose` + * Refactored from `event` to `property` (`event Action RequestClose;` -> `DialogCloseListener RequestClose { get; }`) + * Property is now read-only +* `IDialogService` moved to Prism.Core + * Deprecated `void Show(...)` + * Deprecated `void ShowDialog(Window owner, ...` + +**Removed Files:** + +| File | Status | Notes | +|-------------------------|---------|--------| +| `ButtonResult.cs` | :x: | Absorbed into `Prism.Core` +| `DialogParameters.cs` | :x: | Absorbed into `Prism.Core` +| `DialogResult.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogParameters.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogResult.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogService.cs` | :white_square_button: :x: | Absorbed into `Prism.Core` +| `IDialogServiceExtensions.cs` | :x: | Absorbed into `Prism.Core` +| `IDialogServiceCompatExtensions` | :new: +| `KnownDialogParameters` | :new: + +**Not Implemented:** + +* `IDialogWindow.Style` - Custom window styles are not implemented at this time. +* `DialogWindow.axaml.cs` - Does not implement `this.AttachDevTools();` at this time - _would be helpful during debugging_ + +**Avalonia vs WPF:** + +| Avalonia | WPF | Reference | +|-|-|-| +| `dialogWindow.Opened` | `dialogWindow.Loaded` +| `EventHandler? Closing;` | `event CancelEventHandler Closing;` | `IDialogWindow.cs` + +#### Prism.DryIoc.Avalonia + +| File | Status | Notes | +|-------------------------------------|---------|--------| +| DryIocContainerExtension.cs | :x: | [New Prism.Container Packages](https://github.com/PrismLibrary/Prism/pull/2968) + +#### Prism.Avalonia.Tests + +| File | Status | Notes | +|-------------------------------------|---------|--------| +| MockHostAwareRegionBehavior.cs | :heavy_check_mark: +| MockPresentationRegion.cs | :heavy_check_mark: +| MockRegion.cs | :heavy_check_mark: +| MockRegionAdapter.cs | :heavy_check_mark: +| MockRegionBehavior.cs | :heavy_check_mark: +| MockRegionBehaviorCollection.cs | :heavy_check_mark: +| MockRegionManager.cs | :heavy_check_mark: +| MockRegionmanagerAccessor.cs | :heavy_check_mark: +| MockSortableViews.cs | :heavy_check_mark: +| MockViewsCollection.cs | :heavy_check_mark: +| PrismApplicationBaseFixture.cs | :heavy_check_mark: +| PrismBootstrapperBaseFixture.cs | :heavy_check_mark: +| AutoPopulateRegionBehaviorFixture.cs | :heavy_check_mark: +| RegionActiveAwareBehaviorFixture.cs | :heavy_check_mark: +| RegionManagerRegistrationBehaviorFixture.cs | :heavy_check_mark: +| RegionMemberlifetimeBehaviorFixture.cs | :heavy_check_mark: +| ContentControlRegionAdapterFixture.cs | :heavy_check_mark: +| RegionAdapterBaseFixture.cs | :heavy_check_mark: +| RegionBehaviorFixture.cs | :heavy_check_mark: +| RegionFixture.cs | :heavy_check_mark: +| RegionManagerRequestNavigateFixture.cs | :heavy_check_mark: +| RegionViewRegistryFixture.cs | :heavy_check_mark: + +### Future Feature Work To Add + +| Project | Class | +|-|-| +| Prism.Avalonia | `Interactivity/InvokeCommandAction` +| Prism.Avalonia.Tests | `Regions/ItemsControlRegionAdapterFixture` +| Prism.Avalonia.Tests | `Regions/SelectorRegionAdapterFixture` + +## Upgrading from Prism 7.2 to 8.1 + * Basis of comparison: [Prism Library v7.2.0.1422...v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) -## Action Items +### Action Items * [X] Upgrade Prism.Avalonia * [X] Upgrade Prism.DryIoc @@ -28,14 +142,14 @@ * This requires Avalonia v0.11 and [PR #8277](https://github.com/AvaloniaUI/Avalonia/pull/8277) as per [Issue 7908](https://github.com/AvaloniaUI/Avalonia/issues/7908). * Restructure folders to match PrismLibrary -## Upgrade Progress +### Upgrade Progress | File | Status | Notes | |-----------------------|---------|--------| | Readme.md | :warning: | Needs updated to match 8.1.x NuGet package version | src\Readme.md | :new: | Added from PrismLibrary v8.1.x -### Prism.Avalonia +#### Prism.Avalonia | File | Status | Notes | |-------------------------------------|---------|--------| @@ -178,7 +292,7 @@ | Services\Dialogs\IDialogWindow.cs | :new: :heavy_check_mark: | Services\Dialogs\IDialogWindowExtensions.cs | :new: :heavy_check_mark: -### Containers +#### Containers Containers is a :new: Folder @@ -193,7 +307,7 @@ Containers is a :new: Folder | Containers\Prism.Unity.Shared\PrismIocExntensions.cs | :new: | Containers\Prism.Unity.Shared\UnityContainerExtension.cs | :new: -### Prism.DryIoc.Avalonia +#### Prism.DryIoc.Avalonia | File | Status | Notes | |-------------------------------------|---------|--------| @@ -210,7 +324,7 @@ Containers is a :new: Folder | Properties\Resources.Designer.resx | :white_square_button: | Properties\Resources.resx | :white_square_button: -### Prism.Unity.Avalonia +#### Prism.Unity.Avalonia | File | Status | Notes | |-------------------------------------|---------|--------| @@ -218,7 +332,7 @@ Containers is a :new: Folder | PrismBootstrapper.cs | :heavy_check_mark: | GlobalSuppressions.cs | :heavy_check_mark: -### Tests - Prism.Avalonia.Tests +#### Tests - Prism.Avalonia.Tests Test writted to [Prism.WPF specs](https://github.com/PrismLibrary/Prism/tree/master/tests/Wpf/Prism.Wpf.Tests). @@ -319,28 +433,20 @@ Test writted to [Prism.WPF specs](https://github.com/PrismLibrary/Prism/tree/mas | Regions\Behaviors\SelectorItemsSourceSyncRegionBehaviorFixture.cs | :white_square_button: :warning: | Regions\Behaviors\SyncRegionContextWithHostBehaviorFixture.cs | :heavy_check_mark: -### Tests - Prism.Container.Avalonia.Shared +#### Tests - Prism.Container.Avalonia.Shared | File | Status | Notes | |-----------------------------------------------|---------|--------| | Fixtures\ContainerExtensionCollection.cs | :heavy_check_mark: | | Mocks\NullModuleCatalogBootstrapper.cs | :heavy_check_mark: | -### Tests - Prism.DryIoc.Avalonia.Tests +#### Tests - Prism.DryIoc.Avalonia.Tests **_TBD_** | File | Status | Notes | |-----------------------------------------------|---------|--------| -## Prism Upgrade Comparison - -As we all know, not everything is straight forward between these two XAML technologies. However, it's a good reminder to document the differences and 'got-yas'. - -* [Prism v7.2.0.1422 to v8.0.0.1909](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.0.0.1909) -* [Prism v7.2.0.1422 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v7.2.0.1422...v8.1.97) -* [Prism v8.0.0.1909 to v8.1.97](https://github.com/PrismLibrary/Prism/compare/v8.0.0.1909...v8.1.97) - ## Conversion Helpers [https://docs.avaloniaui.net/misc/wpf/Control-frameworkelement-and-control] @@ -361,7 +467,7 @@ As we all know, not everything is straight forward between these two XAML techno | `System.Windows.DependencyPropertyChangedEventArgs` | `Avalonia.AvaloniaPropertyChangedEventArgs` | `System.ComponentModel.DesignerProperties.GetIsInDesignMode(DependencyObject element);` | `Avalonia.Controls.Design.IsDesignMode;` | `System.Windows.Controls.Primitives.Selector` | ?? | _used by `SelectorRegionAdapter.cs` and `PrismInitializationExtensions.cs`_ -| `RoutedEventHandler` | _Not Implemented_ +| `RoutedEventHandler` | `EventHandler` ### AvaloniaProperty vs DependencyProperty diff --git a/build/AvaloniaDependency.props b/build/AvaloniaDependency.props index fd5be6a..d86f649 100644 --- a/build/AvaloniaDependency.props +++ b/build/AvaloniaDependency.props @@ -2,9 +2,9 @@ - - - + + + diff --git a/build/Base.props b/build/Base.props index 6aec944..5c99317 100644 --- a/build/Base.props +++ b/build/Base.props @@ -2,7 +2,7 @@ - 9.0.264.11073 + 9.0.271.11074-pre https://github.com/AvaloniaCommunity/Prism.Avalonia Copyright (c) 2024 Xeno Innovations, Inc. MIT diff --git a/build/PrismDependency.props b/build/PrismDependency.props index 18af5dd..97976e1 100644 --- a/build/PrismDependency.props +++ b/build/PrismDependency.props @@ -3,8 +3,8 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - - + + diff --git a/build/SampleApp.props b/build/SampleApp.props index f06c124..3faa810 100644 --- a/build/SampleApp.props +++ b/build/SampleApp.props @@ -6,12 +6,12 @@ - - - - - - + + + + + + diff --git a/e2e/DummyModule1/DummyModule1.cs b/e2e/DummyModule1/DummyModule1.cs index 49b62e7..1cc6bf9 100644 --- a/e2e/DummyModule1/DummyModule1.cs +++ b/e2e/DummyModule1/DummyModule1.cs @@ -9,7 +9,7 @@ using Prism.Ioc; ////using Prism.Logging; using Prism.Modularity; -using Prism.Regions; +using Prism.Navigation.Regions; namespace DummyModule { diff --git a/e2e/DummyModule1/Views/DummyModuleView.axaml b/e2e/DummyModule1/Views/DummyModuleView.axaml index e812dc5..ee2af0c 100644 --- a/e2e/DummyModule1/Views/DummyModuleView.axaml +++ b/e2e/DummyModule1/Views/DummyModuleView.axaml @@ -1,6 +1,6 @@  diff --git a/e2e/SampleDialogApp/App.axaml.cs b/e2e/SampleDialogApp/App.axaml.cs index 239c0c8..de348e8 100644 --- a/e2e/SampleDialogApp/App.axaml.cs +++ b/e2e/SampleDialogApp/App.axaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using Avalonia; using Avalonia.Markup.Xaml; using Prism.DryIoc; @@ -27,5 +27,6 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) containerRegistry.Register(); containerRegistry.RegisterDialog(); containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialogWindow(nameof(CustomDialogWindow)); } } diff --git a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs index 5ae8716..b04c84b 100644 --- a/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/DialogViewModel.cs @@ -2,7 +2,7 @@ using Avalonia.Controls; using Prism.Commands; using Prism.Mvvm; -using Prism.Services.Dialogs; +using Prism.Dialogs; using SampleDialogApp.Views; namespace SampleDialogApp.ViewModels; @@ -12,6 +12,8 @@ public class DialogViewModel : BindableBase, IDialogAware private readonly IDialogService _dialogService; private string _customMessage = string.Empty; private string _title = "Notification"; + + /// Custom Prism.Avalonia feature. private Window? _parentWindow = null; public DialogViewModel(IDialogService dialogService) @@ -23,45 +25,75 @@ public DialogViewModel(IDialogService dialogService) Title = "I'm a Sample Dialog!"; } + // New: v9.0.271-pre + public DialogCloseListener RequestClose { get; } + public string Title { get => _title; set => SetProperty(ref _title, value); } + // Custom Prism.Avalonia feature /// Gets or sets the optional parent window of this Dialog pop-up. public Window? ParentWindow { get => _parentWindow; set => SetProperty(ref _parentWindow, value); } public DelegateCommand CmdModalDialog => new(() => { var title = "MessageBox Title Here"; - var message = "Hello, I am a modal MessageBox window.\n\n" + - $"I {(ParentWindow == null ? "dont" : "do")} have a parent."; + var message = "Hello, I am a modal MessageBox called via the ViewModel.\n\n" + + "My parent window is the DialogView's window."; + + // v9.0.271 + _dialogService.ShowDialog( + name: nameof(MessageBoxView), + parameters: new DialogParameters($"title={title}&message={message}") + { + // This informs the DialogService to use this window for MessageBoxView's parent. + { KnownDialogParameters.ParentWindow , ParentWindow }, + }); + + // v8.1.97 + ////_dialogService.ShowDialog( + //// ParentWindow, + //// nameof(MessageBoxView), + //// new DialogParameters($"title={title}&message={message}")); + }); + public DelegateCommand CmdCustomDialogWindow => new(() => + { + // This passes the "title" to the Custom window's Title + // that is based off of it's inner 'MessageBoxView' UserControl. + var title = "Custom Title"; + var message = "Hello, I custom dialog window running inside of Prism.Avalonia!"; + + // NOTE: + // When setting, 'KnownDialogParameters.WindowName' the DialogService + // uses SampleDialogApp's CustomDialogWindow instead of + // Prism.Avalonia's default DialogWindow. _dialogService.ShowDialog( - ParentWindow, - nameof(MessageBoxView), - new DialogParameters($"title={title}&message={message}")); + name: nameof(MessageBoxView), + new DialogParameters + { + { "title", title }, + { "message", message }, + { KnownDialogParameters.WindowName, nameof(CustomDialogWindow) } + }); }); public DelegateCommand CmdResult => new DelegateCommand((param) => { - // None = 0 - // OK = 1 - // Cancel = 2 - // Abort = 3 - // Retry = 4 - // Ignore = 5 - // Yes = 6 - // No = 7 + // None = 0, OK = 1, Cancel = 2, Abort = 3, Retry = 4, Ignore = 5, Yes = 6, No = 7 ButtonResult result = ButtonResult.None; if (int.TryParse(param, out int intResult)) result = (ButtonResult)intResult; - RaiseRequestClose(new DialogResult(result)); + // NEW: 9.0.271-pre + RequestClose.Invoke(result); + + // OLD: v8.1.97 + ////RaiseRequestClose(new DialogResult(result)); }); public string CustomMessage { get => _customMessage; set => SetProperty(ref _customMessage, value); } - public event Action? RequestClose; - public virtual bool CanCloseDialog() { // Allow the dialog to close @@ -78,8 +110,9 @@ public void OnDialogOpened(IDialogParameters parameters) CustomMessage = parameters.GetValue("message"); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) - { - RequestClose?.Invoke(dialogResult); - } + // OLD: v8.1.97 + ////public virtual void RaiseRequestClose(IDialogResult dialogResult) + ////{ + //// RequestClose?.Invoke(dialogResult); + ////} } diff --git a/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs b/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs index 35f4db1..f7c41b6 100644 --- a/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/MainWindowViewModel.cs @@ -1,5 +1,5 @@ using Prism.Commands; -using Prism.Services.Dialogs; +using Prism.Dialogs; using SampleDialogApp.Views; namespace SampleDialogApp.ViewModels; @@ -22,7 +22,7 @@ public MainWindowViewModel(IDialogService dialogService) var message = "Hello, I am a simple MessageBox modal window with an OK button.\n\n" + "When too much text is added, a scrollbar will appear."; - _dialogService.ShowDialog(nameof(MessageBoxView), new DialogParameters($"title={title}&message={message}"), r => { }); + _dialogService.ShowDialog(nameof(MessageBoxView), new DialogParameters($"title={title}&message={message}")); }); public DelegateCommand CmdShowDialog => new DelegateCommand(() => diff --git a/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs b/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs index 1f2340b..03f1a46 100644 --- a/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs +++ b/e2e/SampleDialogApp/ViewModels/MessageBoxViewModel.cs @@ -1,7 +1,7 @@ using System; using Prism.Commands; using Prism.Mvvm; -using Prism.Services.Dialogs; +using Prism.Dialogs; namespace SampleDialogApp.ViewModels; @@ -27,7 +27,11 @@ public MessageBoxViewModel() MaxWidth = 600; } - public event Action? RequestClose; + // v9.0.271-pre + public DialogCloseListener RequestClose { get; } + + // v8.1.97 + // public event Action? RequestClose; public string Title { get => _title; set => SetProperty(ref _title, value); } @@ -37,29 +41,23 @@ public MessageBoxViewModel() public DelegateCommand CmdResult => new DelegateCommand((param) => { - // None = 0 - // OK = 1 - // Cancel = 2 - // Abort = 3 - // Retry = 4 - // Ignore = 5 - // Yes = 6 - // No = 7 + // None = 0, OK = 1, Cancel = 2, Abort = 3, Retry = 4, Ignore = 5, Yes = 6, No = 7 ButtonResult result = ButtonResult.None; if (int.TryParse(param, out int intResult)) result = (ButtonResult)intResult; - RaiseRequestClose(new DialogResult(result)); + // v9.0.271-pre + RequestClose.Invoke(result); + + // v8.1.97 + // RaiseRequestClose(new DialogResult(result)); }); public string CustomMessage { get => _customMessage; set => SetProperty(ref _customMessage, value); } - public virtual bool CanCloseDialog() - { - // Allow the dialog to close - return true; - } + /// Allow the dialog to close + public virtual bool CanCloseDialog() => true; public virtual void OnDialogClosed() { @@ -75,8 +73,9 @@ public void OnDialogOpened(IDialogParameters parameters) CustomMessage = parameters.GetValue("message"); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) - { - RequestClose?.Invoke(dialogResult); - } + // v8.1.97 + ////public virtual void RaiseRequestClose(IDialogResult dialogResult) + ////{ + //// RequestClose?.Invoke(dialogResult); + ////} } diff --git a/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs b/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs index 2c46342..299a6d1 100644 --- a/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs +++ b/e2e/SampleDialogApp/ViewModels/ViewModelBase.cs @@ -1,5 +1,5 @@ using Prism.Mvvm; -using Prism.Regions; +using Prism.Navigation.Regions; namespace SampleDialogApp.ViewModels; diff --git a/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml new file mode 100644 index 0000000..d2152b9 --- /dev/null +++ b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs new file mode 100644 index 0000000..ab78ee2 --- /dev/null +++ b/e2e/SampleDialogApp/Views/CustomDialogWindow.axaml.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Prism.Dialogs; + +namespace SampleDialogApp.Views; + +/// Custom dialog window host. +public partial class CustomDialogWindow : Window, IDialogWindow +{ + public CustomDialogWindow() + { + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + } + + /// The of the dialog. + public IDialogResult Result { get; set; } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/e2e/SampleDialogApp/Views/DialogView.axaml b/e2e/SampleDialogApp/Views/DialogView.axaml index 2e697ce..e07d3ad 100644 --- a/e2e/SampleDialogApp/Views/DialogView.axaml +++ b/e2e/SampleDialogApp/Views/DialogView.axaml @@ -1,4 +1,4 @@ - + +