Refactor StundePage to MVVM with DI
This commit is contained in:
@@ -8,10 +8,6 @@
|
||||
x:Class="Jugenddienst_Stunden.Views.StundePage"
|
||||
Title="{Binding Title}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<models:StundeViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<conv:IntBoolConverter x:Key="IntBoolConverter" />
|
||||
|
||||
@@ -13,14 +13,13 @@ public partial class StundePage : ContentPage {
|
||||
/// <summary>
|
||||
/// CTOR
|
||||
/// </summary>
|
||||
public StundePage() {
|
||||
public StundePage(StundeViewModel vm) {
|
||||
InitializeComponent();
|
||||
|
||||
if (BindingContext is StundeViewModel vm) {
|
||||
vm.AlertEvent += Vm_AlertEvent;
|
||||
vm.InfoEvent += Vm_InfoEvent;
|
||||
vm.ConfirmEvent += ShowConfirm;
|
||||
}
|
||||
BindingContext = vm;
|
||||
vm.AlertEvent += Vm_AlertEvent;
|
||||
vm.InfoEvent += Vm_InfoEvent;
|
||||
vm.ConfirmEvent += ShowConfirm;
|
||||
}
|
||||
|
||||
private void Vm_AlertEvent(object? sender, string e) {
|
||||
|
||||
Reference in New Issue
Block a user