Added MyFirstStyletProject

This commit is contained in:
Anastasios Zampelis 2020-12-29 15:47:00 +02:00
parent 823e01073d
commit f043700f2c
25 changed files with 1153 additions and 0 deletions

362
.gitignore vendored Normal file
View File

@ -0,0 +1,362 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Stylet" Version="1.3.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyFirstStyletProject.Shared\MyFirstStyletProject.Shared.csproj" />
<ProjectReference Include="..\MyStyletExamples.DataAccess\MyStyletExamples.DataAccess.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
using MyFirstStyletProject.Shared.Interfaces;
using MyStyletExamples.DataAccess;
using StyletIoC;
using System;
using System.Collections.Generic;
using System.Text;
namespace MyFirstStyletProject.IoC
{
public class MyStyletIoCModule : StyletIoCModule
{
protected override void Load()
{
Bind<IStaffRepository>().To<StaffRepository>().InSingletonScope();
}
}
}

View File

@ -0,0 +1,12 @@
using MyFirstStyletProject.Shared.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace MyFirstStyletProject.Shared.Interfaces
{
public interface IStaffRepository
{
List<Employee> GetEmployees();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace MyFirstStyletProject.Shared.Models
{
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Avatar { get; set; }
public string JobTitle { get; set; }
public string Email { get; set; }
public string About { get; set; }
}
}

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,13 @@
<Application x:Class="MyFirstStyletProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:local="clr-namespace:MyFirstStyletProject">
<Application.Resources>
<s:ApplicationLoader>
<s:ApplicationLoader.Bootstrapper>
<local:Bootstrapper/>
</s:ApplicationLoader.Bootstrapper>
</s:ApplicationLoader>
</Application.Resources>
</Application>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MyFirstStyletProject
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@ -0,0 +1,20 @@
using MyFirstStyletProject.IoC;
using MyFirstStyletProject.ViewModels;
using Stylet;
using StyletIoC;
namespace MyFirstStyletProject
{
public class Bootstrapper : Bootstrapper<ShellViewModel>
{
protected override void ConfigureIoC(IStyletIoCBuilder builder)
{
builder.AddModule(new MyStyletIoCModule());
}
protected override void Configure()
{
// Perform any other configuration before the application starts
}
}
}

View File

@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<RootNamespace>MyFirstStyletProject</RootNamespace>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\icon.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
<PackageReference Include="Stylet" Version="1.3.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyFirstStyletProject.IoC\MyFirstStyletProject.IoC.csproj" />
<ProjectReference Include="..\MyFirstStyletProject.Shared\MyFirstStyletProject.Shared.csproj" />
<ProjectReference Include="..\MyStyletExamples.DataAccess\MyStyletExamples.DataAccess.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MyFirstStyletProject.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyFirstStyletProject.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon {
get {
object obj = ResourceManager.GetObject("icon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

View File

@ -0,0 +1,13 @@
using Stylet;
namespace MyFirstStyletProject.ViewModels
{
public class ShellViewModel : Conductor<IScreen>.StackNavigation
{
public ShellViewModel(StaffViewModel staffViewModel)
{
this.DisplayName = string.Empty;
this.ActivateItem(staffViewModel);
}
}
}

View File

@ -0,0 +1,27 @@
using MyFirstStyletProject.Shared.Models;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFirstStyletProject.ViewModels
{
public class StaffDetailsViewModel : Screen
{
public StaffDetailsViewModel() { }
private Employee _employee;
public Employee Employee
{
get => _employee;
set => SetAndNotify(ref _employee, value);
}
public void GoBack()
{
this.RequestClose();
}
}
}

View File

@ -0,0 +1,39 @@
using MyFirstStyletProject.Shared.Interfaces;
using MyFirstStyletProject.Shared.Models;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFirstStyletProject.ViewModels
{
public class StaffViewModel : Screen
{
private readonly IStaffRepository _staffData;
public StaffViewModel(IStaffRepository staffData)
{
_staffData = staffData;
}
private List<Employee> _employees;
public List<Employee> Employees
{
get => _employees;
set => SetAndNotify(ref _employees, value);
}
protected override void OnInitialActivate()
{
Employees = _staffData.GetEmployees();
}
public void StaffDetails(Employee employee)
{
var staffDetailsVM = new StaffDetailsViewModel { Employee = employee };
((ShellViewModel)this.Parent).ActivateItem(staffDetailsVM);
}
}
}

View File

@ -0,0 +1,22 @@
<Window x:Class="MyFirstStyletProject.Views.ShellView"
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:s="https://github.com/canton7/Stylet"
xmlns:local="clr-namespace:MyFirstStyletProject.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:ShellViewModel}"
Title="Stylet Project" Height="450" Width="800"
WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Choose a person from below:" FontSize="20"/>
<ContentControl s:View.Model="{Binding ActiveItem}" Grid.Row="1"/>
</Grid>
</Window>

View File

@ -0,0 +1,20 @@
using System;
using System.Windows;
using System.Windows.Media.Imaging;
namespace MyFirstStyletProject.Views
{
/// <summary>
/// Interaction logic for ShellView.xaml
/// </summary>
public partial class ShellView : Window
{
public ShellView()
{
InitializeComponent();
//Set Build Action as Resource
Icon = new BitmapImage(new Uri(@"pack://application:,,,/Resources/icon.png"));
}
}
}

View File

@ -0,0 +1,80 @@
<UserControl x:Class="MyFirstStyletProject.Views.StaffDetailsView"
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:MyFirstStyletProject.Views"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Foreground="White">
<UserControl.Resources>
<Style x:Key="CustomButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Blue"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<ContentPresenter Content="{TemplateBinding Content}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.2" ScaleY="1.2"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<Button Style="{StaticResource CustomButtonStyle}" Cursor="Hand"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="20"
Foreground="White"
Command="{s:Action GoBack}" Content="Go Back">
</Button>
<Grid VerticalAlignment="Center" Margin="80,0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image Width="150" Height="150" Stretch="UniformToFill"
Source="{Binding Employee.Avatar}"/>
<Grid Grid.Column="1" Margin="15,0,0,0"
VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock FontWeight="SemiBold" FontSize="28">
<Run Text="{Binding Employee.FirstName}"/>
<Run Text="{Binding Employee.LastName}"/>
</TextBlock>
<TextBlock Grid.Row="1" Foreground="LightGray"
Text="{Binding Employee.JobTitle}"/>
<TextBlock Grid.Row="2" Foreground="#FF879EAE"
Text="{Binding Employee.Email}" Margin="0,4,0,0"/>
</Grid>
</Grid>
<!-- About -->
<TextBlock Grid.Row="1" Margin="0,20,0,0" TextWrapping="Wrap"
Text="{Binding Employee.About}" TextAlignment="Justify"/>
</Grid>
</Grid>
</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 MyFirstStyletProject.Views
{
/// <summary>
/// Interaction logic for StaffDetailsView.xaml
/// </summary>
public partial class StaffDetailsView : UserControl
{
public StaffDetailsView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,89 @@
<UserControl x:Class="MyFirstStyletProject.Views.StaffView"
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:MyFirstStyletProject.Views"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:models="clr-namespace:MyFirstStyletProject.Shared.Models;assembly=MyFirstStyletProject.Shared"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<DataTemplate x:Key="StaffDataTemplate" DataType="{x:Type models:Employee}">
<Border Margin="10" Cursor="Hand" BorderThickness="1"
Background="#FF16394F" BorderBrush="#FF3F5666"
CornerRadius="8" Width="200" Height="240">
<Grid VerticalAlignment="Center" Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Pic -->
<Grid SnapsToDevicePixels="True" HorizontalAlignment="Center" VerticalAlignment="Center"
Width="100" Height="100">
<Grid.OpacityMask>
<VisualBrush Visual="{Binding ElementName=ClipEllipse}"/>
</Grid.OpacityMask>
<Ellipse x:Name="ClipEllipse" Fill="White" Stroke="Black" StrokeThickness="1"/>
<Image Source="{Binding Avatar}" Stretch="UniformToFill"/>
<Ellipse Stroke="#FF112E42" StrokeThickness="1"/>
</Grid>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="0,10,0,0"
VerticalAlignment="Top" HorizontalAlignment="Stretch">
<!-- Name -->
<TextBlock FontWeight="SemiBold" FontSize="18"
TextAlignment="Center" TextWrapping="Wrap"
Foreground="White">
<Run Text="{Binding FirstName}"/>
<Run Text="{Binding LastName}"/>
</TextBlock>
<!-- Title -->
<TextBlock Margin="0,5,0,0" TextAlignment="Center" TextWrapping="Wrap"
Foreground="LightGray"
Text="{Binding JobTitle}"/>
</StackPanel>
</Grid>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="MouseLeftButtonUp">
<behaviors:InvokeCommandAction Command="{s:Action StaffDetails}"
CommandParameter="{Binding}"/>
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</Border>
</DataTemplate>
</UserControl.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<Grid ScrollViewer.CanContentScroll="True">
<ListBox HorizontalAlignment="Center" VerticalAlignment="Center"
ItemTemplate="{StaticResource StaffDataTemplate}"
ItemsSource="{Binding Employees}">
<ListBox.Template>
<!-- This change prevents the ListBox from clipping the data template when it scales. -->
<ControlTemplate TargetType="{x:Type ListBox}">
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="1" SnapsToDevicePixels="True">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="3"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
</ScrollViewer>
</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 MyFirstStyletProject.Views
{
/// <summary>
/// Interaction logic for StaffView.xaml
/// </summary>
public partial class StaffView : UserControl
{
public StaffView()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Bogus" Version="32.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyFirstStyletProject.Shared\MyFirstStyletProject.Shared.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,26 @@
using Bogus;
using MyFirstStyletProject.Shared.Interfaces;
using MyFirstStyletProject.Shared.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace MyStyletExamples.DataAccess
{
public class StaffRepository : IStaffRepository
{
public List<Employee> GetEmployees()
{
var faker = new Faker<Employee>()
.RuleFor(e => e.FirstName, (f, e) => f.Name.FirstName())
.RuleFor(e => e.LastName, (f, e) => f.Name.LastName())
.RuleFor(e => e.Avatar, f => f.Internet.Avatar())
.RuleFor(e => e.Email, (f, e) => f.Internet.Email(e.FirstName, e.LastName))
.RuleFor(e => e.JobTitle, f => f.Name.JobTitle())
.RuleFor(e => e.About, f => f.Lorem.Paragraph(10));
return faker.Generate(10);
}
}
}

View File

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyFirstStyletProject", "MyFirstStyletProject\MyFirstStyletProject.csproj", "{53555521-7461-4A7D-8144-6984CC6D2F4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyFirstStyletProject.Shared", "MyFirstStyletProject.Shared\MyFirstStyletProject.Shared.csproj", "{1DFED542-68F0-49D5-83F5-49E383155903}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyFirstStyletProject.IoC", "MyFirstStyletProject.IoC\MyFirstStyletProject.IoC.csproj", "{D778EC71-2747-4605-9DEE-FD2E399CB772}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyStyletExamples.DataAccess", "MyStyletExamples.DataAccess\MyStyletExamples.DataAccess.csproj", "{F33DF940-E1FF-477B-81EC-28719EEF6FAE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53555521-7461-4A7D-8144-6984CC6D2F4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53555521-7461-4A7D-8144-6984CC6D2F4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53555521-7461-4A7D-8144-6984CC6D2F4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53555521-7461-4A7D-8144-6984CC6D2F4C}.Release|Any CPU.Build.0 = Release|Any CPU
{1DFED542-68F0-49D5-83F5-49E383155903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DFED542-68F0-49D5-83F5-49E383155903}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DFED542-68F0-49D5-83F5-49E383155903}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DFED542-68F0-49D5-83F5-49E383155903}.Release|Any CPU.Build.0 = Release|Any CPU
{D778EC71-2747-4605-9DEE-FD2E399CB772}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D778EC71-2747-4605-9DEE-FD2E399CB772}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D778EC71-2747-4605-9DEE-FD2E399CB772}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D778EC71-2747-4605-9DEE-FD2E399CB772}.Release|Any CPU.Build.0 = Release|Any CPU
{F33DF940-E1FF-477B-81EC-28719EEF6FAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F33DF940-E1FF-477B-81EC-28719EEF6FAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F33DF940-E1FF-477B-81EC-28719EEF6FAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F33DF940-E1FF-477B-81EC-28719EEF6FAE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {81976B23-619E-40C9-AD7F-F6C825119E38}
EndGlobalSection
EndGlobal