diff --git a/README.md b/README.md
index 6e79940..cd4e1c3 100644
--- a/README.md
+++ b/README.md
@@ -16,16 +16,16 @@ https://jamsoft.github.io/JamSoft.AvaloniaUI.Dialogs/
## Installation
```shell
-dotnet add package JamSoft.AvaloniaUI.Dialogs --version 1.1.4
+dotnet add package JamSoft.AvaloniaUI.Dialogs --version 1.2.0
```
```shell
-Install-Package JamSoft.AvaloniaUI.Dialogs -Version 1.1.4
+Install-Package JamSoft.AvaloniaUI.Dialogs -Version 1.2.0
```
```xml
-
+
```
```shell
-paket add JamSoft.AvaloniaUI.Dialogs --version 1.1.4
+paket add JamSoft.AvaloniaUI.Dialogs --version 1.2.0
```
## Import Styles
### All Defaults
@@ -368,7 +368,8 @@ See the Sample Application for a complete implementation example and guidance.
You can easily target elements of the dialogs via their names and types, such as:
```xml
-
+
+
@@ -382,7 +383,13 @@ You can easily target elements of the dialogs via their names and types, such as
-
+
+
+
+
```
\ No newline at end of file
diff --git a/src/JamSoft.AvaloniaUI.Dialogs.Sample/App.axaml b/src/JamSoft.AvaloniaUI.Dialogs.Sample/App.axaml
index e59edd5..e0f60fb 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs.Sample/App.axaml
+++ b/src/JamSoft.AvaloniaUI.Dialogs.Sample/App.axaml
@@ -4,7 +4,11 @@
x:Class="JamSoft.AvaloniaUI.Dialogs.Sample.App">
-
+
+
+
+
+
-
+
+
+
+
diff --git a/src/JamSoft.AvaloniaUI.Dialogs.Sample/JamSoft.AvaloniaUI.Dialogs.Sample.csproj b/src/JamSoft.AvaloniaUI.Dialogs.Sample/JamSoft.AvaloniaUI.Dialogs.Sample.csproj
index 292d3fe..6df7f59 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs.Sample/JamSoft.AvaloniaUI.Dialogs.Sample.csproj
+++ b/src/JamSoft.AvaloniaUI.Dialogs.Sample/JamSoft.AvaloniaUI.Dialogs.Sample.csproj
@@ -1,10 +1,12 @@
WinExe
- net7.0
+ net8.0
enable
true
app.manifest
+ 12
+ Assets\avalonia-logo.ico
@@ -18,15 +20,15 @@
-
-
+
+
+
-
-
+
+
-
-
-
+
+
diff --git a/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/CustomBaseChildWindowViewModel.cs b/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/CustomBaseChildWindowViewModel.cs
index e44ed53..f3b3f53 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/CustomBaseChildWindowViewModel.cs
+++ b/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/CustomBaseChildWindowViewModel.cs
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel;
using System.Windows.Input;
-using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Imaging;
@@ -20,9 +19,7 @@ public CustomBaseChildWindowViewModel()
{
AcceptCommand = new DelegateCommand(null, null);
CancelCommand = new DelegateCommand(null, null);
-
- var assets = AvaloniaLocator.Current.GetService();
- CloseIcon = new Bitmap(assets?.Open(new Uri("avares://JamSoft.AvaloniaUI.Dialogs/Assets/CloseIcon/icons8-close-30.png")));
+ CloseIcon = new Bitmap(AssetLoader.Open(new Uri("avares://JamSoft.AvaloniaUI.Dialogs/Assets/CloseIcon/icons8-close-30.png")));
_cancelCommand = new DelegateCommand(() => InvokeRequestCloseDialog(new RequestCloseDialogEventArgs(false)), CanCancel);
CancelCommandText = "Cancel";
diff --git a/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/MainWindowViewModel.cs b/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/MainWindowViewModel.cs
index 2f9154f..2cbcd94 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/MainWindowViewModel.cs
+++ b/src/JamSoft.AvaloniaUI.Dialogs.Sample/ViewModels/MainWindowViewModel.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Windows.Input;
using Avalonia.Controls;
+using Avalonia.Platform.Storage;
using JamSoft.AvaloniaUI.Dialogs.Commands;
using JamSoft.AvaloniaUI.Dialogs.Helpers;
using JamSoft.AvaloniaUI.Dialogs.Sample.Models;
@@ -14,7 +15,6 @@ namespace JamSoft.AvaloniaUI.Dialogs.Sample.ViewModels;
public class MainWindowViewModel : ViewModelBase
{
private readonly IDialogService _dialogService;
- private string? _message;
private ICommand? _openFileCommand;
private ICommand? _openWordFileCommand;
private ICommand? _saveFileCommand;
@@ -29,7 +29,8 @@ public class MainWindowViewModel : ViewModelBase
private ICommand? _childWindowRememberPositionCommand;
private ICommand? _missingViewCommand;
private ICommand? _wizardViewCommand;
-
+ private string? _message;
+
public MainWindowViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
@@ -137,12 +138,6 @@ public ICommand? SaveWordFileCommand
set => this.RaiseAndSetIfChanged(ref _saveWordFileCommand, value);
}
- public string? Message
- {
- get => _message;
- set => this.RaiseAndSetIfChanged(ref _message, value);
- }
-
public ICommand? OpenFileCommand
{
get => _openFileCommand;
@@ -155,6 +150,12 @@ public ICommand? OpenWordFileCommand
set => this.RaiseAndSetIfChanged(ref _openWordFileCommand, value);
}
+ public string? Message
+ {
+ get => _message;
+ set => this.RaiseAndSetIfChanged(ref _message, value);
+ }
+
private async void OpenFileCommandExecuted()
{
Message = await _dialogService.OpenFile("Open Any File");
@@ -162,7 +163,7 @@ private async void OpenFileCommandExecuted()
private async void OpenWordFileCommandExecuted()
{
- Message = await _dialogService.OpenFile("Open Word File", new List
+ Message = await _dialogService.OpenFile("Open Word File", new List
{
CommonFilters.WordFilter
});
@@ -180,7 +181,7 @@ private async void SaveFileCommandExecuted()
private async void SaveWordFileCommandExecuted()
{
- Message = await _dialogService.SaveFile("Save Word File", new List
+ Message = await _dialogService.SaveFile("Save Word File", new List
{
CommonFilters.WordFilter
});
diff --git a/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyChildWindowView.axaml b/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyChildWindowView.axaml
index bdd5fa4..e156415 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyChildWindowView.axaml
+++ b/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyChildWindowView.axaml
@@ -8,7 +8,7 @@
-
diff --git a/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyWizardView.axaml b/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyWizardView.axaml
index d8120f0..56f0f8d 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyWizardView.axaml
+++ b/src/JamSoft.AvaloniaUI.Dialogs.Sample/Views/MyWizardView.axaml
@@ -8,7 +8,7 @@
x:Class="JamSoft.AvaloniaUI.Dialogs.Sample.Views.MyWizardView">
@@ -16,7 +16,7 @@
Page 1
-
@@ -54,7 +54,7 @@
-
+
diff --git a/src/JamSoft.AvaloniaUI.Dialogs/Controls/Wizard.cs b/src/JamSoft.AvaloniaUI.Dialogs/Controls/Wizard.cs
index dde642e..b9d8c0e 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs/Controls/Wizard.cs
+++ b/src/JamSoft.AvaloniaUI.Dialogs/Controls/Wizard.cs
@@ -1,13 +1,12 @@
using System.Windows.Input;
using Avalonia;
-using Avalonia.Collections;
using Avalonia.Controls;
-using Avalonia.Controls.Generators;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
-using Avalonia.LogicalTree;
+using Avalonia.Data;
+using Avalonia.Metadata;
using JamSoft.AvaloniaUI.Dialogs.Commands;
using JamSoft.AvaloniaUI.Dialogs.ViewModels;
@@ -16,17 +15,53 @@ namespace JamSoft.AvaloniaUI.Dialogs.Controls
///
/// A wizard control that displays a series of elements in a workflow style progression.
///
- [TemplatePart("PART_StepsPresenter", typeof(ItemsPresenter))]
+ [TemplatePart("PART_StepsPresenter", typeof(ItemsControl))]
[TemplatePart("PART_ButtonsPresenter", typeof(DockPanel))]
- public class Wizard : SelectingItemsControl, IContentPresenterHost
+ public class Wizard : TemplatedControl
{
+ internal ContentPresenter? ContentPart;
+
+ internal DockPanel? ButtonsPresenterPart { get; private set; }
+
+ private Button? CompleteButton { get; set; }
+
+ private Button? PreviousButton { get; set; }
+
+ private Button? NextButton { get; set; }
+
private ICommand MoveNextCommand => new DelegateCommand(MoveNextCommandExecuted);
private ICommand MovePreviousCommand => new DelegateCommand(MovePreviousCommandExecuted);
+
+ ///
+ /// Gets or sets the selected item.
+ ///
+ public WizardStep? SelectedItem { get; set; }
+
+ ///
+ /// The index of the active WizardStep
+ ///
+ public int SelectedIndex { get; set; }
///
- /// The default value for the property.
+ /// Defines the property.
///
- private static readonly FuncTemplate DefaultPanel = new(() => new WrapPanel());
+ public static readonly DirectProperty SelectedIndexProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(SelectedIndex),
+ o => o.SelectedIndex,
+ (o, v) => o.SelectedIndex = v,
+ unsetValue: 0,
+ defaultBindingMode: BindingMode.OneWay);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly DirectProperty SelectedItemProperty =
+ AvaloniaProperty.RegisterDirect(
+ nameof(SelectedItem),
+ o => o.SelectedItem,
+ (o, v) => o.SelectedItem = v,
+ defaultBindingMode: BindingMode.OneWay, enableDataValidation: true);
///
/// Defines the property.
@@ -43,7 +78,7 @@ public class Wizard : SelectingItemsControl, IContentPresenterHost
///
/// Defines the property.
///
- public static readonly StyledProperty ContentTemplateProperty =
+ public static readonly StyledProperty ContentTemplateProperty =
ContentControl.ContentTemplateProperty.AddOwner();
///
@@ -61,31 +96,45 @@ public class Wizard : SelectingItemsControl, IContentPresenterHost
///
/// Defines the property.
///
- public static readonly StyledProperty
diff --git a/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStepStyle.axaml b/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStepStyle.axaml
index 05c59fd..7c514ca 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStepStyle.axaml
+++ b/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStepStyle.axaml
@@ -34,7 +34,7 @@
CornerRadius="{TemplateBinding CornerRadius}"
Padding="{TemplateBinding Padding}">
-
+
diff --git a/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStyle.axaml b/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStyle.axaml
index 4a34feb..3b44c2c 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStyle.axaml
+++ b/src/JamSoft.AvaloniaUI.Dialogs/Themes/WizardStyle.axaml
@@ -40,13 +40,17 @@
DockPanel.Dock="{TemplateBinding ButtonPlacement}"
LastChildFill="False"/>
-
-
+
+
+
+
+
+
+
+
+
+
@@ -72,9 +78,11 @@
+
+
diff --git a/src/JamSoft.AvaloniaUI.Dialogs/ViewModels/ChildWindowViewModel.cs b/src/JamSoft.AvaloniaUI.Dialogs/ViewModels/ChildWindowViewModel.cs
index 1016b9c..3cf9c4b 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs/ViewModels/ChildWindowViewModel.cs
+++ b/src/JamSoft.AvaloniaUI.Dialogs/ViewModels/ChildWindowViewModel.cs
@@ -1,5 +1,4 @@
-using Avalonia;
-using Avalonia.Controls;
+using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
@@ -23,8 +22,7 @@ public abstract class ChildWindowViewModel : DialogViewModel, IChildWindowViewMo
///
protected ChildWindowViewModel()
{
- var assets = AvaloniaLocator.Current.GetService();
- _closeIcon = new Bitmap(assets?.Open(new Uri("avares://JamSoft.AvaloniaUI.Dialogs/Assets/CloseIcon/icons8-close-30.png")));
+ _closeIcon = new Bitmap(AssetLoader.Open(new Uri("avares://JamSoft.AvaloniaUI.Dialogs/Assets/CloseIcon/icons8-close-30.png")));
}
///
diff --git a/src/JamSoft.AvaloniaUI.Dialogs/Views/ChildWindow.axaml.cs b/src/JamSoft.AvaloniaUI.Dialogs/Views/ChildWindow.axaml.cs
index 8234b91..e5502e6 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs/Views/ChildWindow.axaml.cs
+++ b/src/JamSoft.AvaloniaUI.Dialogs/Views/ChildWindow.axaml.cs
@@ -2,6 +2,7 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
+using Avalonia.Reactive;
using JamSoft.AvaloniaUI.Dialogs.Events;
using JamSoft.AvaloniaUI.Dialogs.ViewModels;
@@ -25,8 +26,8 @@ public ChildWindow()
#if DEBUG
this.AttachDevTools();
#endif
- this.FindControl("ChromeDockPanel").PointerPressed += OnChromePointerPressed;
- this.FindControl("Host").DataContextChanged += DialogPresenterDataContextChanged;
+ this.FindControl("ChromeDockPanel")!.PointerPressed += OnChromePointerPressed;
+ this.FindControl("Host")!.DataContextChanged += DialogPresenterDataContextChanged;
Closed += ChildWindowClosed;
PositionChanged += OnPositionChanged;
}
@@ -46,14 +47,14 @@ private void OnChromePointerPressed(object? sender, PointerPressedEventArgs e)
var p = e.GetCurrentPoint(null);
if (p.Properties.IsLeftButtonPressed)
{
- ClientSizeProperty.Changed.Subscribe(size =>
+ this.GetObservable(ClientSizeProperty).Subscribe(new AnonymousObserver((s)=>
{
- if (ReferenceEquals(size.Sender, this))
- {
+ //if (ReferenceEquals(size.Sender, this))
+ //{
_vm.RequestedLeft = Position.X;
_vm.RequestedTop = Position.Y;
- }
- });
+ //}
+ }));
BeginMoveDrag(e);
e.Handled = false;
diff --git a/src/JamSoft.AvaloniaUI.Dialogs/Views/DialogWindow.axaml.cs b/src/JamSoft.AvaloniaUI.Dialogs/Views/DialogWindow.axaml.cs
index 14812cc..a23aa97 100644
--- a/src/JamSoft.AvaloniaUI.Dialogs/Views/DialogWindow.axaml.cs
+++ b/src/JamSoft.AvaloniaUI.Dialogs/Views/DialogWindow.axaml.cs
@@ -22,7 +22,7 @@ public DialogWindow()
#if DEBUG
this.AttachDevTools();
#endif
- this.FindControl("Host").DataContextChanged += DialogPresenterDataContextChanged;
+ this.FindControl("Host")!.DataContextChanged += DialogPresenterDataContextChanged;
Closed += DialogWindowClosed;
}