Daten werden nun geladen

This commit is contained in:
HuskyTeufel
2021-05-05 13:32:46 +02:00
parent af01e537cf
commit 5d89391e93
20 changed files with 236 additions and 170 deletions

6
GuiWPF/App.config Normal file
View 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>

View File

@@ -1,7 +1,7 @@
<Application x:Class="GuiWPF.App" <Application x:Class="WPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GuiWPF" xmlns:local="clr-namespace:WPF"
StartupUri="MainWindow.xaml"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>

View File

@@ -6,13 +6,12 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
namespace GuiWPF namespace WPF
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaktionslogik für "App.xaml"
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
} }
} }

View File

@@ -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)
)]

View File

@@ -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; using System.Windows.Input;
namespace GuiWPF { namespace WPF
public class DelegateCommand : ICommand { {
public class DelegateCommand : ICommand
{
/// <summary> /// <summary>
/// Action to be performed when this command is executed /// Action to be performed when this command is executed
/// </summary> /// </summary>

View 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>

View File

@@ -1,5 +1,13 @@
namespace GuiWPF { using System;
public class HomePage { using System.Collections.Generic;
public string PageTitle {get;set;} using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WPF
{
public class HomePage
{
public string PageTitle { get; set; }
} }
} }

View File

@@ -1,12 +1,13 @@
<UserControl x:Class="GuiWPF.HomePageView" <UserControl x:Class="WPF.HomePageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPF"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<Button Content="lool"></Button> <TextBlock FontSize="20" Text="{Binding Path=PageTitle}" />
<TextBlock FontSize="20" Text="Lala" />
</Grid> </Grid>
</UserControl> </UserControl>

View 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();
}
}
}

View File

@@ -1,27 +1,26 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace GuiWPF namespace WPF
{ {
public class HomePageViewModel : ViewModelBase { public class HomePageViewModel : ViewModelBase
//public string PageTitle = "HomePage"; {
public HomePage Model {get; private set;} public HomePageViewModel(HomePage model)
public HomePageViewModel(HomePage model) { {
this.Model = model; this.Model = model;
} }
public HomePage Model { get; private set; }
public string PageTitle { public string PageTitle
get { {
return Model.PageTitle; get => this.Model.PageTitle;
} set
set { {
Model.PageTitle = value; this.Model.PageTitle = value;
OnPropertyChanged(); this.OnPropertyChanged("PageTitle");
} }
} }
} }
} }

View File

@@ -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();
}
}
}

View File

@@ -1,11 +1,11 @@
<Window x:Class="GuiWPF.MainWindow" <Window x:Class="WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GuiWPF" xmlns:local="clr-namespace:WPF"
mc:Ignorable="d" mc:Ignorable="d"
Title="{Binding PageTitle, StringFormat={} DP - {0}}" Height="450" Width="800"> Title="MainWindow" Height="450" Width="800">
<Window.Resources> <Window.Resources>
<DataTemplate DataType="{x:Type local:HomePageViewModel}"> <DataTemplate DataType="{x:Type local:HomePageViewModel}">
<local:HomePageView /> <local:HomePageView />
@@ -17,8 +17,8 @@
<DockPanel> <DockPanel>
<StackPanel DockPanel.Dock="Left"> <StackPanel DockPanel.Dock="Left">
<Button Content="Home Page" Command="{Binding Path=LoadHomePageCommand}" /> <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> </StackPanel>
<ContentControl Content="{Binding CurrentViewModel}" Name="Contenter"></ContentControl> <ContentControl Content="{Binding Path=CurrentViewModel}" />
</DockPanel> </DockPanel>
</Window> </Window>

View File

@@ -13,17 +13,17 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace GuiWPF namespace WPF
{ {
/// <summary> /// <summary>
/// Interaction logic for MainWindow.xaml /// Interaktionslogik für MainWindow.xaml
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
public MainWindow() public MainWindow()
{ {
//InitializeComponent(); InitializeComponent();
//this.DataContext = new MainViewModel(); this.DataContext = new MainWindowViewModel();
} }
} }
} }

View 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" });
}
}
}

View File

@@ -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
View 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; }
}
}

View File

@@ -1,11 +1,12 @@
<UserControl x:Class="GuiWPF.SettingsPageView" <UserControl x:Class="WPF.SettingsPageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPF"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<TextBlock FontSize="20" Text="{Binding Path=PageTitle}" /> <TextBlock FontSize="20" Text="{Binding Path=PageTitle}" />
</Grid> </Grid>
</UserControl> </UserControl>

View 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();
}
}
}

View File

@@ -1,11 +1,26 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace GuiWPF namespace WPF
{ {
public class SettingsPageViewModel : ViewModelBase { public class SettingsPageViewModel : ViewModelBase
public string PageTitle = "SettingsPage"; {
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");
}
}
} }
} }

View File

@@ -1,37 +1,25 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace GuiWPF namespace WPF
{ {
public class ViewModelBase : NotificationObject public abstract class ViewModelBase : INotifyPropertyChanged
{ {
private bool valIsBusy; public event PropertyChangedEventHandler PropertyChanged;
private string valBusyMessage; protected void OnPropertyChanged(string propertyName)
{
this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
public bool IsBusy protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{ {
get => valIsBusy; var handler = this.PropertyChanged;
set if (handler != null)
{ handler(this, e);
if(valIsBusy != value)
{
valIsBusy = value;
OnPropertyChanged();
}
}
}
public string BusyMessage
{
get => valBusyMessage;
set
{
if(valBusyMessage != value)
{
valBusyMessage = value;
OnPropertyChanged();
}
}
} }
} }
} }