Viewmodel erweitert
This commit is contained in:
@@ -24,17 +24,17 @@ namespace KanSan.UI
|
||||
{
|
||||
//private Kunde kunde = null;
|
||||
//private UnitOfWork unitOfWork = null;
|
||||
public UCKundeEdit()
|
||||
public UCKundeEdit(Kunde kunde = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
this.DataContext = new KundeViewModel();
|
||||
this.DataContext = new KundenEditViewModel(kunde);
|
||||
}
|
||||
|
||||
private void Speichern_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((KundeViewModel)DataContext).Speichern();
|
||||
((KundenEditViewModel)DataContext).Speichern();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
17
KanSan/UI/Kunde/UCKundeList.xaml
Normal file
17
KanSan/UI/Kunde/UCKundeList.xaml
Normal file
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="KanSan.UI.UCKundeList"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:KanSan.UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid ItemsSource="{Binding Kunden}" />
|
||||
<Button Grid.Row="1" Name="NeueKunde" Content="Neue Kunde anlegen" Click="NeueKunde_Click" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
50
KanSan/UI/Kunde/UCKundeList.xaml.cs
Normal file
50
KanSan/UI/Kunde/UCKundeList.xaml.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace KanSan.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für UCKundeList.xaml
|
||||
/// </summary>
|
||||
public partial class UCKundeList : UserControl
|
||||
{
|
||||
|
||||
public UCKundeList()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = new KundenListViewModel();
|
||||
}
|
||||
|
||||
private void NeueKunde_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
KundeAddedKlickEventArgs args = new KundeAddedKlickEventArgs();
|
||||
args.kunde = (DataContext as KundenListViewModel).NeueKunde();
|
||||
OnKlickedKunde(args);
|
||||
|
||||
}
|
||||
protected virtual void OnKlickedKunde(KundeAddedKlickEventArgs e)
|
||||
{
|
||||
EventHandler<KundeAddedKlickEventArgs> handler = KundeAdded;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
public event EventHandler<KundeAddedKlickEventArgs> KundeAdded;
|
||||
}
|
||||
|
||||
public class KundeAddedKlickEventArgs : EventArgs
|
||||
{
|
||||
public Kunde kunde { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user