Added Slop
This commit is contained in:
46
Views/DeductionSearchDialog.axaml.cs
Normal file
46
Views/DeductionSearchDialog.axaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Lagerprogramm.Models;
|
||||
using Lagerprogramm.ViewModels;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Lagerprogramm.Views;
|
||||
|
||||
public partial class DeductionSearchDialog : Window
|
||||
{
|
||||
public Deduction? SelectedDeduction { get; private set; }
|
||||
|
||||
public DeductionSearchDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
KeyDown += OnKeyDown;
|
||||
}
|
||||
|
||||
public async Task<Deduction?> ShowDeductionSearch(ObservableCollection<Deduction> deductions, Window parent)
|
||||
{
|
||||
SelectedDeduction = null;
|
||||
var viewModel = new DeductionSearchDialogViewModel(deductions);
|
||||
DataContext = viewModel;
|
||||
await ShowDialog(parent);
|
||||
return SelectedDeduction;
|
||||
}
|
||||
|
||||
private void OnDoubleTapped(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (DeductionListBox.SelectedItem is Deduction deduction)
|
||||
{
|
||||
SelectedDeduction = deduction;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter && DeductionListBox.SelectedItem is Deduction deduction)
|
||||
{
|
||||
SelectedDeduction = deduction;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user