diff --git a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml
index 933a7b3..8ffe642 100644
--- a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml
+++ b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml
@@ -32,6 +32,10 @@
+
+
@@ -47,20 +51,9 @@
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
UsePickerType="{Binding #UsePickerType.Value}"
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
- SelectedPaths="{Binding Paths,Mode=OneWayToSource}">
-
-
-
-
+ SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
+ Command="{Binding SelectedCommand}"
+ IsCancelingPickerAlsoTriggers="{Binding #IsCancelingPickerAlsoTriggers.IsChecked}">
@@ -73,11 +66,13 @@
AllowMultiple="{Binding #AllowMultiple.IsChecked}"
UsePickerType="{Binding #UsePickerType.Value}"
SelectedPathsText="{Binding Path,Mode=OneWayToSource}"
- SelectedPaths="{Binding Paths,Mode=OneWayToSource}">
+ SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
+ Command="{Binding SelectedCommand}"
+ IsCancelingPickerAlsoTriggers="{Binding #IsCancelingPickerAlsoTriggers.IsChecked}">
-
+ SelectedPaths="{Binding Paths,Mode=OneWayToSource}"
+ Command="{Binding SelectedCommand}"
+ IsCancelingPickerAlsoTriggers="{Binding #IsCancelingPickerAlsoTriggers.IsChecked}">
+
diff --git a/demo/Ursa.Demo/ViewModels/PathPickerDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/PathPickerDemoViewModel.cs
index 307556d..6bb9d2a 100644
--- a/demo/Ursa.Demo/ViewModels/PathPickerDemoViewModel.cs
+++ b/demo/Ursa.Demo/ViewModels/PathPickerDemoViewModel.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
namespace Ursa.Demo.ViewModels;
@@ -7,4 +8,11 @@ public partial class PathPickerDemoViewModel : ViewModelBase
{
[ObservableProperty] private string? _path;
[ObservableProperty] private IReadOnlyList? _paths;
+ [ObservableProperty] private int _commandTriggerCount = 0;
+
+ [RelayCommand]
+ private void Selected(IReadOnlyList paths)
+ {
+ CommandTriggerCount++;
+ }
}
\ No newline at end of file
diff --git a/src/Ursa.Themes.Semi/Controls/PathPicker.axaml b/src/Ursa.Themes.Semi/Controls/PathPicker.axaml
index 5ff8c86..cc0ec95 100644
--- a/src/Ursa.Themes.Semi/Controls/PathPicker.axaml
+++ b/src/Ursa.Themes.Semi/Controls/PathPicker.axaml
@@ -11,32 +11,31 @@
Content="{TemplateBinding Title}"
Margin="1,0,0,0">
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/Ursa/Controls/PathPicker/PathPicker.cs b/src/Ursa/Controls/PathPicker/PathPicker.cs
index 992c6b7..647147c 100644
--- a/src/Ursa/Controls/PathPicker/PathPicker.cs
+++ b/src/Ursa/Controls/PathPicker/PathPicker.cs
@@ -54,6 +54,16 @@ public class PathPicker : TemplatedControl
AvaloniaProperty.Register(
nameof(SelectedPathsText), defaultBindingMode: BindingMode.TwoWay);
+ public static readonly StyledProperty IsCancelingPickerAlsoTriggersProperty =
+ AvaloniaProperty.Register(
+ nameof(IsCancelingPickerAlsoTriggers));
+
+ public bool IsCancelingPickerAlsoTriggers
+ {
+ get => GetValue(IsCancelingPickerAlsoTriggersProperty);
+ set => SetValue(IsCancelingPickerAlsoTriggersProperty, value);
+ }
+
public string? SelectedPathsText
{
get => GetValue(SelectedPathsTextProperty);
@@ -129,7 +139,7 @@ public class PathPicker : TemplatedControl
{
_twoConvertLock = true;
var stringBuilder = new StringBuilder();
- stringBuilder.Append(SelectedPaths.FirstOrDefault());
+ stringBuilder.Append(SelectedPaths[0]);
foreach (var item in SelectedPaths.Skip(1))
{
stringBuilder.AppendLine(item);
@@ -268,7 +278,7 @@ public class PathPicker : TemplatedControl
throw new ArgumentOutOfRangeException();
}
- if (SelectedPaths.Count != 0)
+ if (SelectedPaths.Count != 0 || IsCancelingPickerAlsoTriggers)
Command?.Execute(SelectedPaths);
}
catch (Exception exception)