diff --git a/src/Avalonia.Dialogs/Avalonia.Dialogs.csproj b/src/Avalonia.Dialogs/Avalonia.Dialogs.csproj
index dd476e2559c..665693a6541 100644
--- a/src/Avalonia.Dialogs/Avalonia.Dialogs.csproj
+++ b/src/Avalonia.Dialogs/Avalonia.Dialogs.csproj
@@ -4,9 +4,6 @@
-
- Designer
-
diff --git a/src/Avalonia.Dialogs/ChildFitter.cs b/src/Avalonia.Dialogs/ChildFitter.cs
index 744d455d9df..4a6db62b327 100644
--- a/src/Avalonia.Dialogs/ChildFitter.cs
+++ b/src/Avalonia.Dialogs/ChildFitter.cs
@@ -4,7 +4,7 @@
namespace Avalonia.Dialogs
{
- internal class ChildFitter : Decorator
+ public class ChildFitter : Decorator
{
protected override Size MeasureOverride(Size availableSize)
{
diff --git a/src/Avalonia.Dialogs/FileSizeStringConverter.cs b/src/Avalonia.Dialogs/FileSizeStringConverter.cs
index 5b41b9da35e..c2cdf1e5021 100644
--- a/src/Avalonia.Dialogs/FileSizeStringConverter.cs
+++ b/src/Avalonia.Dialogs/FileSizeStringConverter.cs
@@ -6,7 +6,7 @@
namespace Avalonia.Dialogs
{
- internal class FileSizeStringConverter : IValueConverter
+ public class FileSizeStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
diff --git a/src/Avalonia.Dialogs/ManagedFileChooser.xaml.cs b/src/Avalonia.Dialogs/ManagedFileChooser.cs
similarity index 66%
rename from src/Avalonia.Dialogs/ManagedFileChooser.xaml.cs
rename to src/Avalonia.Dialogs/ManagedFileChooser.cs
index 7f29407ed57..f9f38ac4748 100644
--- a/src/Avalonia.Dialogs/ManagedFileChooser.xaml.cs
+++ b/src/Avalonia.Dialogs/ManagedFileChooser.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
@@ -10,17 +11,14 @@
namespace Avalonia.Dialogs
{
- internal class ManagedFileChooser : UserControl
+ public class ManagedFileChooser : TemplatedControl
{
private Control _quickLinksRoot;
private ListBox _filesView;
public ManagedFileChooser()
{
- AvaloniaXamlLoader.Load(this);
AddHandler(PointerPressedEvent, OnPointerPressed, RoutingStrategies.Tunnel);
- _quickLinksRoot = this.FindControl("QuickLinks");
- _filesView = this.FindControl("Files");
}
ManagedFileChooserViewModel Model => DataContext as ManagedFileChooserViewModel;
@@ -34,19 +32,22 @@ private void OnPointerPressed(object sender, PointerPressedEventArgs e)
return;
}
- var isQuickLink = _quickLinksRoot.IsLogicalAncestorOf(e.Source as Control);
- if (e.ClickCount == 2 || isQuickLink)
+ if (_quickLinksRoot != null)
{
- if (model.ItemType == ManagedFileChooserItemType.File)
+ var isQuickLink = _quickLinksRoot.IsLogicalAncestorOf(e.Source as Control);
+ if (e.ClickCount == 2 || isQuickLink)
{
- Model?.SelectSingleFile(model);
+ if (model.ItemType == ManagedFileChooserItemType.File)
+ {
+ Model?.SelectSingleFile(model);
+ }
+ else
+ {
+ Model?.Navigate(model.Path);
+ }
+
+ e.Handled = true;
}
- else
- {
- Model?.Navigate(model.Path);
- }
-
- e.Handled = true;
}
}
@@ -79,10 +80,16 @@ protected override async void OnDataContextChanged(EventArgs e)
// Workaround for ListBox bug, scroll to the previous file
var indexOfPreselected = model.Items.IndexOf(preselected);
- if (indexOfPreselected > 1)
+ if ((_filesView != null) && (indexOfPreselected > 1))
{
_filesView.ScrollIntoView(indexOfPreselected - 1);
}
}
+
+ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+ {
+ _quickLinksRoot = e.NameScope.Get("QuickLinks");
+ _filesView = e.NameScope.Get("Files");
+ }
}
}
diff --git a/src/Avalonia.Dialogs/ManagedFileChooser.xaml b/src/Avalonia.Dialogs/ManagedFileChooser.xaml
deleted file mode 100644
index 227cc1afc05..00000000000
--- a/src/Avalonia.Dialogs/ManagedFileChooser.xaml
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Show hidden files
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Avalonia.Dialogs/ResourceSelectorConverter.cs b/src/Avalonia.Dialogs/ResourceSelectorConverter.cs
index 9d8b6cb1c7d..c8226b98e4a 100644
--- a/src/Avalonia.Dialogs/ResourceSelectorConverter.cs
+++ b/src/Avalonia.Dialogs/ResourceSelectorConverter.cs
@@ -5,7 +5,7 @@
namespace Avalonia.Dialogs
{
- internal class ResourceSelectorConverter : ResourceDictionary, IValueConverter
+ public class ResourceSelectorConverter : ResourceDictionary, IValueConverter
{
public object Convert(object key, Type targetType, object parameter, CultureInfo culture)
{
diff --git a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj
index 153e21761e0..06859e0cbbe 100644
--- a/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj
+++ b/src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj
@@ -12,6 +12,7 @@
+
diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml b/src/Avalonia.Themes.Default/DefaultTheme.xaml
index 4ae9ea4812c..109fde390cc 100644
--- a/src/Avalonia.Themes.Default/DefaultTheme.xaml
+++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml
@@ -62,4 +62,5 @@
+
diff --git a/src/Avalonia.Themes.Default/ManagedFileChooser.xaml b/src/Avalonia.Themes.Default/ManagedFileChooser.xaml
new file mode 100644
index 00000000000..f9f77bf4551
--- /dev/null
+++ b/src/Avalonia.Themes.Default/ManagedFileChooser.xaml
@@ -0,0 +1,153 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj
index 72f1fbf9730..d0bc8e9d26c 100644
--- a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj
+++ b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj
@@ -11,7 +11,8 @@
-
+
+
diff --git a/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml b/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
index 16e05ffdfd0..51836255efc 100644
--- a/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
+++ b/src/Avalonia.Themes.Fluent/Controls/FluentControls.xaml
@@ -61,4 +61,6 @@
+
+
diff --git a/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml b/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml
new file mode 100644
index 00000000000..7ba54405911
--- /dev/null
+++ b/src/Avalonia.Themes.Fluent/Controls/ManagedFileChooser.xaml
@@ -0,0 +1,324 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file