Mitarbeit bewerten begonnen, Schülerdaten, Gruppen
This commit is contained in:
@@ -1,3 +1,48 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Desktop.ViewModels.Students;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Students;
|
||||
public partial class StudentDetailView : UserControl { public StudentDetailView() => InitializeComponent(); }
|
||||
|
||||
public partial class StudentDetailView : UserControl
|
||||
{
|
||||
public StudentDetailView() => InitializeComponent();
|
||||
|
||||
protected override void OnDataContextChanged(EventArgs e)
|
||||
{
|
||||
base.OnDataContextChanged(e);
|
||||
if (DataContext is not StudentDetailViewModel vm) return;
|
||||
vm.OnEditContact = ShowContactDialog;
|
||||
vm.OnViewAddress = ShowAddressViewer;
|
||||
}
|
||||
|
||||
private async Task<Contact?> ShowContactDialog(Contact? contact)
|
||||
{
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null) return null;
|
||||
|
||||
var vm = new ContactEditDialogViewModel(contact);
|
||||
var dialog = new ContactEditDialog { DataContext = vm };
|
||||
var saved = await dialog.ShowDialog<bool>(owner);
|
||||
return saved ? vm.Result : null;
|
||||
}
|
||||
|
||||
private void ShowAddressViewer(ContactItem contact)
|
||||
{
|
||||
if (!contact.HasAddress) return;
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
var viewer = new AddressViewerWindow { DataContext = contact };
|
||||
if (owner is not null)
|
||||
viewer.Show(owner);
|
||||
else
|
||||
viewer.Show();
|
||||
}
|
||||
|
||||
private void OnContactDoubleTapped(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is StudentDetailViewModel vm &&
|
||||
vm.ViewSelectedAddressCommand.CanExecute(null))
|
||||
vm.ViewSelectedAddressCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user