presence_sample_v2/Presence.Desktop/Views/GroupView.axaml.cs

37 lines
1.1 KiB
C#
Raw Normal View History

2024-12-06 08:04:11 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
2024-12-04 08:11:13 +00:00
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
2024-12-06 08:04:11 +00:00
using Avalonia.Platform.Storage;
2024-12-04 08:11:13 +00:00
using Avalonia.ReactiveUI;
using Presence.Desktop.ViewModels;
using ReactiveUI;
namespace Presence.Desktop.Views
{
public partial class GroupView : ReactiveUserControl<GroupViewModel>
{
public GroupView()
{
2024-12-06 08:04:11 +00:00
this.WhenActivated(action =>
{
action(ViewModel!.SelectFileInteraction.RegisterHandler(ShowFileDialog));
});
2024-12-04 08:11:13 +00:00
AvaloniaXamlLoader.Load(this);
}
2024-12-06 08:04:11 +00:00
private async Task ShowFileDialog(IInteractionContext<string?, string?> context)
{
var topLevel = TopLevel.GetTopLevel(this);
var storageFile = await topLevel.StorageProvider.OpenFilePickerAsync(
new FilePickerOpenOptions()
{
AllowMultiple = false,
Title = context.Input
}
);
context.SetOutput(storageFile.First().Path.ToString());
}
2024-12-04 08:11:13 +00:00
}
}