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

37 lines
1.1 KiB
C#
Raw Permalink Normal View History

2024-12-08 15:27:37 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
2024-12-08 15:00:30 +00:00
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
2024-12-08 15:27:37 +00:00
using Avalonia.Platform.Storage;
2024-12-08 15:00:30 +00:00
using Avalonia.ReactiveUI;
using Presence.Desktop.ViewModels;
using ReactiveUI;
2024-12-08 15:27:37 +00:00
namespace Presence.Desktop.Views
2024-12-08 15:00:30 +00:00
{
2024-12-08 15:27:37 +00:00
public partial class GroupView : ReactiveUserControl<GroupViewModel>
2024-12-08 15:00:30 +00:00
{
2024-12-08 15:27:37 +00:00
public GroupView()
{
this.WhenActivated(action =>
{
action(ViewModel!.SelectFileInteraction.RegisterHandler(ShowFileDialog));
});
AvaloniaXamlLoader.Load(this);
}
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-08 15:00:30 +00:00
}
}