diff --git a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml
index 50fa8c1..fc6fc0f 100644
--- a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml
+++ b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml
@@ -16,7 +16,7 @@
Content="PathPicker aggregates a file selector and provides a Command property. The Command is triggered solely after opening the file selector and selecting a file, whereupon the Command receives an IReadOnlyList<string> parameter.">
-
+
@@ -29,18 +29,19 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -48,11 +49,12 @@
-
-
+
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
+
-
+
+
-
+
-
+
+
-
+
-
+
-
-
+
diff --git a/src/Ursa/Controls/PathPicker/PathPicker.cs b/src/Ursa/Controls/PathPicker/PathPicker.cs
index e4e69d2..6cb2b2e 100644
--- a/src/Ursa/Controls/PathPicker/PathPicker.cs
+++ b/src/Ursa/Controls/PathPicker/PathPicker.cs
@@ -5,19 +5,17 @@ using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
-using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Logging;
using Avalonia.Platform.Storage;
-using Avalonia.Threading;
-using Irihi.Avalonia.Shared.Common;
using Irihi.Avalonia.Shared.Helpers;
namespace Ursa.Controls;
-[TemplatePart(Name = "PART_Button", Type = typeof(Button))]
+[TemplatePart(Name = PART_Button, Type = typeof(Button))]
public class PathPicker : TemplatedControl
{
+ public const string PART_Button = "PART_Button";
public static readonly StyledProperty SuggestedStartPathProperty =
AvaloniaProperty.Register(
nameof(SuggestedStartPath), string.Empty);
@@ -185,7 +183,7 @@ public class PathPicker : TemplatedControl
{
base.OnApplyTemplate(e);
Button.ClickEvent.RemoveHandler(LaunchPicker, _button);
- _button = e.NameScope.Find("PART_Button");
+ _button = e.NameScope.Find(PART_Button);
Button.ClickEvent.AddHandler(LaunchPicker, _button);
}
@@ -243,7 +241,7 @@ public class PathPicker : TemplatedControl
try
{
if (TopLevel.GetTopLevel(this)?.StorageProvider is not { } storageProvider) return;
-
+ _button?.SetValue(IsEnabledProperty, false);
switch (UsePickerType)
{
case UsePickerTypes.OpenFile:
@@ -273,7 +271,7 @@ public class PathPicker : TemplatedControl
?.TryGetLocalPath();
UpdateSelectedPaths(string.IsNullOrEmpty(path)
? Array.Empty()
- : [path!]);
+ : [path]);
break;
case UsePickerTypes.OpenFolder:
FolderPickerOpenOptions folderPickerOpenOptions = new()
@@ -298,8 +296,10 @@ public class PathPicker : TemplatedControl
{
Logger.TryGet(LogEventLevel.Error, LogArea.Control)?.Log(this, $"{exception}");
}
-
- return;
+ finally
+ {
+ _button?.SetValue(IsEnabledProperty, true);
+ }
}
private void UpdateSelectedPaths(IReadOnlyList newList)