forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddItemDialog.xaml.cs
51 lines (41 loc) · 1.36 KB
/
AddItemDialog.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.
using Files.App.ViewModels.Dialogs;
using Files.App.ViewModels.Dialogs.AddItemDialog;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace Files.App.Dialogs
{
public sealed partial class AddItemDialog : ContentDialog, IDialog<AddItemDialogViewModel>, IRealTimeControl
{
private readonly IAddItemService addItemService = Ioc.Default.GetRequiredService<IAddItemService>();
private FrameworkElement RootAppElement
=> (FrameworkElement)MainWindow.Instance.Content;
public AddItemDialogViewModel ViewModel
{
get => (AddItemDialogViewModel)DataContext;
set => DataContext = value;
}
public AddItemDialog()
{
InitializeComponent();
InitializeContentLayout();
}
public new async Task<DialogResult> ShowAsync()
{
return (DialogResult)await base.ShowAsync();
}
private void ListView_ItemClick(object sender, ItemClickEventArgs e)
{
ViewModel.ResultType = (e.ClickedItem as AddItemDialogListItemViewModel).ItemResult;
Hide();
}
private async void AddItemDialog_Loaded(object sender, RoutedEventArgs e)
{
var itemTypes = addItemService.GetEntries();
await ViewModel.AddItemsToListAsync(itemTypes);
// Focus on the list view so users can use keyboard navigation
AddItemsListView.Focus(FocusState.Programmatic);
}
}
}