Skip to content
Merged
3 changes: 0 additions & 3 deletions src/Avalonia.Dialogs/Avalonia.Dialogs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
</PropertyGroup>

<ItemGroup>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<AvaloniaResource Include="Assets\*" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Dialogs/ChildFitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Avalonia.Dialogs
{
internal class ChildFitter : Decorator
public class ChildFitter : Decorator
{
protected override Size MeasureOverride(Size availableSize)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Dialogs/FileSizeStringConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;

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<Control>("QuickLinks");
_filesView = this.FindControl<ListBox>("Files");
}

ManagedFileChooserViewModel Model => DataContext as ManagedFileChooserViewModel;
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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<Control>("QuickLinks");
_filesView = e.NameScope.Get<ListBox>("Files");
}
}
}
144 changes: 0 additions & 144 deletions src/Avalonia.Dialogs/ManagedFileChooser.xaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/Avalonia.Dialogs/ResourceSelectorConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Loading