Daten werden nun geladen
This commit is contained in:
6
GuiWPF/App.config
Normal file
6
GuiWPF/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -1,7 +1,7 @@
|
||||
<Application x:Class="GuiWPF.App"
|
||||
<Application x:Class="WPF.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:GuiWPF"
|
||||
xmlns:local="clr-namespace:WPF"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace GuiWPF
|
||||
namespace WPF
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// Interaktionslogik für "App.xaml"
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly:ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
@@ -1,8 +1,14 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GuiWPF {
|
||||
public class DelegateCommand : ICommand {
|
||||
namespace WPF
|
||||
{
|
||||
public class DelegateCommand : ICommand
|
||||
{
|
||||
/// <summary>
|
||||
/// Action to be performed when this command is executed
|
||||
/// </summary>
|
||||
@@ -72,4 +78,4 @@ namespace GuiWPF {
|
||||
this.executionAction(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
GuiWPF/GuiWPF.csproj.user
Normal file
5
GuiWPF/GuiWPF.csproj.user
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<ItemGroup />
|
||||
</Project>
|
||||
@@ -1,5 +1,13 @@
|
||||
namespace GuiWPF {
|
||||
public class HomePage {
|
||||
public string PageTitle {get;set;}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WPF
|
||||
{
|
||||
public class HomePage
|
||||
{
|
||||
public string PageTitle { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<UserControl x:Class="GuiWPF.HomePageView"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Button Content="lool"></Button>
|
||||
<TextBlock FontSize="20" Text="Lala" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
<UserControl x:Class="WPF.HomePageView"
|
||||
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:WPF"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<TextBlock FontSize="20" Text="{Binding Path=PageTitle}" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
28
GuiWPF/HomePageView.xaml.cs
Normal file
28
GuiWPF/HomePageView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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 WPF
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für HomePageView.xaml
|
||||
/// </summary>
|
||||
public partial class HomePageView : UserControl
|
||||
{
|
||||
public HomePageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,26 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GuiWPF
|
||||
namespace WPF
|
||||
{
|
||||
public class HomePageViewModel : ViewModelBase {
|
||||
//public string PageTitle = "HomePage";
|
||||
public HomePage Model {get; private set;}
|
||||
public HomePageViewModel(HomePage model) {
|
||||
public class HomePageViewModel : ViewModelBase
|
||||
{
|
||||
public HomePageViewModel(HomePage model)
|
||||
{
|
||||
this.Model = model;
|
||||
|
||||
}
|
||||
|
||||
public string PageTitle {
|
||||
get {
|
||||
return Model.PageTitle;
|
||||
}
|
||||
set {
|
||||
Model.PageTitle = value;
|
||||
OnPropertyChanged();
|
||||
public HomePage Model { get; private set; }
|
||||
public string PageTitle
|
||||
{
|
||||
get => this.Model.PageTitle;
|
||||
set
|
||||
{
|
||||
this.Model.PageTitle = value;
|
||||
this.OnPropertyChanged("PageTitle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GuiWPF
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
public string PageTitle { get; set; }
|
||||
public ICommand LoadHomePageCommand {get; private set;}
|
||||
public ICommand LoadSettingsPageCommand {get; private set;}
|
||||
|
||||
private ViewModelBase _currentViewModel;
|
||||
public ViewModelBase CurrentViewModel {
|
||||
get {
|
||||
Trace.WriteLine("CurrentAbgefragt");
|
||||
return _currentViewModel;
|
||||
}
|
||||
set {
|
||||
Trace.WriteLine("CurrentView ist geändert worden");
|
||||
_currentViewModel = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
PageTitle = "Dichtheitsprüfung by Damian";
|
||||
LoadHomePage();
|
||||
LoadHomePageCommand = new DelegateCommand(o => this.LoadHomePage());
|
||||
LoadSettingsPageCommand = new DelegateCommand(o => this.LoadSettingsPage());
|
||||
|
||||
//Initialisieren();
|
||||
}
|
||||
|
||||
private void LoadHomePage() {
|
||||
CurrentViewModel = new HomePageViewModel(new HomePage() { PageTitle = "Home"});
|
||||
}
|
||||
private void LoadSettingsPage() {
|
||||
CurrentViewModel = new SettingsPageViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
<Window x:Class="GuiWPF.MainWindow"
|
||||
<Window x:Class="WPF.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:GuiWPF"
|
||||
xmlns:local="clr-namespace:WPF"
|
||||
mc:Ignorable="d"
|
||||
Title="{Binding PageTitle, StringFormat={} DP - {0}}" Height="450" Width="800">
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Window.Resources>
|
||||
<DataTemplate DataType="{x:Type local:HomePageViewModel}">
|
||||
<local:HomePageView />
|
||||
@@ -17,8 +17,8 @@
|
||||
<DockPanel>
|
||||
<StackPanel DockPanel.Dock="Left">
|
||||
<Button Content="Home Page" Command="{Binding Path=LoadHomePageCommand}" />
|
||||
<Button Content="Settings Page" Command="{Binding Path=LoadSettingsPageCommand}"/>
|
||||
<Button Content="Settings Page" Command="{Binding Path=LoadSettingsPageCommand}" />
|
||||
</StackPanel>
|
||||
<ContentControl Content="{Binding CurrentViewModel}" Name="Contenter"></ContentControl>
|
||||
<ContentControl Content="{Binding Path=CurrentViewModel}" />
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -13,17 +13,17 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace GuiWPF
|
||||
namespace WPF
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// Interaktionslogik für MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
//InitializeComponent();
|
||||
//this.DataContext = new MainViewModel();
|
||||
InitializeComponent();
|
||||
this.DataContext = new MainWindowViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
GuiWPF/MainWindowViewModel.cs
Normal file
45
GuiWPF/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WPF
|
||||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
public ICommand LoadHomePageCommand { get; private set; }
|
||||
public ICommand LoadSettingsPageCommand { get; private set;}
|
||||
|
||||
private ViewModelBase _currentViewModel;
|
||||
public ViewModelBase CurrentViewModel
|
||||
{
|
||||
get => _currentViewModel;
|
||||
set
|
||||
{
|
||||
_currentViewModel = value;
|
||||
OnPropertyChanged("CurrentViewModel");
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
this.LoadHomePage();
|
||||
this.LoadHomePageCommand = new DelegateCommand(o => this.LoadHomePage());
|
||||
this.LoadSettingsPageCommand = new DelegateCommand(o => this.LoadSettingsPage());
|
||||
}
|
||||
|
||||
private void LoadHomePage()
|
||||
{
|
||||
CurrentViewModel = new HomePageViewModel(
|
||||
new HomePage { PageTitle = "This is the Home Page" });
|
||||
}
|
||||
|
||||
private void LoadSettingsPage()
|
||||
{
|
||||
CurrentViewModel = new SettingsPageViewModel(
|
||||
new SettingsPage() { PageTitle = "This is the SettingsPage" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace GuiWPF
|
||||
{
|
||||
public class NotificationObject : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName]string propertyName="")
|
||||
{
|
||||
if(PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
Trace.WriteLine(string.Format("OnPropertyChanged {0}",propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
GuiWPF/SettingsPage.cs
Normal file
13
GuiWPF/SettingsPage.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WPF
|
||||
{
|
||||
public class SettingsPage
|
||||
{
|
||||
public string PageTitle { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
<UserControl x:Class="GuiWPF.SettingsPageView"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<TextBlock FontSize="20" Text="{Binding Path=PageTitle}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
<UserControl x:Class="WPF.SettingsPageView"
|
||||
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:WPF"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<TextBlock FontSize="20" Text="{Binding Path=PageTitle}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
28
GuiWPF/SettingsPageView.xaml.cs
Normal file
28
GuiWPF/SettingsPageView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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 WPF
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaktionslogik für SettingsPageView.xaml
|
||||
/// </summary>
|
||||
public partial class SettingsPageView : UserControl
|
||||
{
|
||||
public SettingsPageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,26 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GuiWPF
|
||||
namespace WPF
|
||||
{
|
||||
public class SettingsPageViewModel : ViewModelBase {
|
||||
public string PageTitle = "SettingsPage";
|
||||
public class SettingsPageViewModel : ViewModelBase
|
||||
{
|
||||
public SettingsPageViewModel(SettingsPage model)
|
||||
{
|
||||
this.Model = model;
|
||||
}
|
||||
public SettingsPage Model { get; private set; }
|
||||
public string PageTitle
|
||||
{
|
||||
get => this.Model.PageTitle;
|
||||
set
|
||||
{
|
||||
this.Model.PageTitle = value;
|
||||
this.OnPropertyChanged("PageTitle");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GuiWPF
|
||||
namespace WPF
|
||||
{
|
||||
public class ViewModelBase : NotificationObject
|
||||
public abstract class ViewModelBase : INotifyPropertyChanged
|
||||
{
|
||||
private bool valIsBusy;
|
||||
private string valBusyMessage;
|
||||
|
||||
public bool IsBusy
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
get => valIsBusy;
|
||||
set
|
||||
{
|
||||
if(valIsBusy != value)
|
||||
{
|
||||
valIsBusy = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
public string BusyMessage
|
||||
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
get => valBusyMessage;
|
||||
set
|
||||
{
|
||||
if(valBusyMessage != value)
|
||||
{
|
||||
valBusyMessage = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
var handler = this.PropertyChanged;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user