Mvvm Pattern erweitert

This commit is contained in:
Husky
2020-02-21 08:50:00 +01:00
parent 183646b4da
commit 5798fc6108
7 changed files with 51 additions and 52 deletions

View File

@@ -13,6 +13,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
@@ -25,6 +26,8 @@
<Label Grid.Column="0" Grid.Row="3">Plz</Label>
<Label Grid.Column="0" Grid.Row="4">Ort</Label>
<Button Name="Speichern" Content="Speichern" Grid.Row="5" Grid.ColumnSpan="2" Click="Speichern_Click" />
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Vorname}" />
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Nachname}" />
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Strasse}" />

View File

@@ -3,6 +3,7 @@ using KanSan.Base.Models;
using KanSan.ViewModel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@@ -21,24 +22,20 @@ namespace KanSan.UI
/// </summary>
public partial class UCKundeEdit : UserControl
{
private Kunde kunde = null;
private UnitOfWork unitOfWork = null;
public UCKundeEdit(Kunde kunde)
//private Kunde kunde = null;
//private UnitOfWork unitOfWork = null;
public UCKundeEdit()
{
InitializeComponent();
this.kunde = kunde;
unitOfWork = new UnitOfWork(new KanSanContext());
KundeViewModel kundeViewModel = new KundeViewModel(kunde);
kundeViewModel.PropertyChanged += KundeViewModel_PropertyChanged;
this.DataContext = kundeViewModel;
this.DataContext = new KundeViewModel();
}
private void KundeViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
private void Speichern_Click(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
((KundeViewModel)DataContext).Speichern();
}
}
}