Lesson 01 Tuesday June 2nd (08:30 – 12:00)
Homework to finish before Lesson 01
Perform the following assignment using Visual Studio 2019:
Exercise: Creating an Object Oriented System for Drawing Shapes using C#
If certain topics appear to be unclear, an explanation of the different object oriented concepts used in this exercise can be found here:
Class Time
During this first lesson we will get acquainted with each other and discuss the topics of the course.
We will use the homework exercise mentioned above to perform a thorough recap of the C# Fundamentals course to see where we all stand knowledge wise and skill wise.
These recap topics will be discussed as well:
- Difference between a Value Type and a Reference Type
👓 ValueTypesVersusReferenceTypes - C# Access Modifiers Quick Reference
- Expression-bodied members
- The 4th Object Oriented Programming Pillar after Abstraction, Encapsulation and Inheritance is Polymorphism
- Enumerations
1. Generics
- Introduction to Generics using C#
👓 GenericsDemo
2. Delegates
Lesson 02 Tuesday June 9th (08:30 – 12:00)
Homework to finish before this lesson
Perform the parts 5, 6, 7 and 8 using Visual Studio 2019.
Exercise: Creating an Object Oriented System for Drawing Shapes using C#
For the parts 6 and 7 this article might be handy:
Class Time
The second lesson will start with a discussion of the homework. Other topics during class time:
- Visual Studio Tip of the Day: CodeLens
- a practical application of delegates: Events in C#
👓 EventDemo - Using enum types as bit flags in C#
- reminder to be sure (and handy for the homework assignment): TryParse
3. Performing Operations Asynchronously
- Asynchronous programming with async and await
👓 SyncAndAsync (Breakfast Example) - Control flow in async programs (C#)
- 💡 all of the above in one drawing: What happens in an async method
👓 AsyncTracerDemo
“Cooking breakfast is a good example of asynchronous work that isn’t parallel”
“It would be as though you stared at the toaster after putting the bread in, ignoring anyone talking to you until the toast popped”
Lesson 03 Tuesday June 16th (08:30 – 12:00)
Homework to finish before this lesson
Perform the parts 9 and 10 using Visual Studio 2019 of this exercise:
Exercise: Creating an Object Oriented System for Drawing Shapes using C#
If there is nothing else for you to watch on Netflix, you could check out Async programming deep dive by Bart De Smet.
Class Time
- Homework Discussion
- The term “Lambda” comes from mathematics, where it’s called lambda calculus. In programming, a Lambda expression (or function) is just an anonymous function (a function with no name)
- Visual Studio Tip of the Day: Track Active Item in Solution Explorer
- Short revisit: Flagged Enum
👓 EnumFlagsDemo - Short revisit: Ref & Out
- Ref versus Out Parameters
- Passing a reference type by reference
👓 Pass Reference Type by Reference
The storage location of the object is passed to the method as the value of the reference parameter.
4. Creating a Windows Desktop Application using WPF
First released as part of .NET Framework 3.0 in 2006
- Overview
- 💡 the letters MIL in milcore.dll stand for Media Integration Layer
- Hello World in WPF
- Starting Point Options
5. Working with XML and XAML
- eXtensible Markup Language (XML)
- eXtensible Application Markup Language (XAML)
6. Creating Modern and Advanced GUIs using WPF
- WPF Layout Classes: Introduction to Panels
Lesson 04 Tuesday June 23th (08:30 – 12:00)
Homework to finish before this lesson
Perform the parts 11, 12 and 13 of this exercise:
Exercise: Creating an Object Oriented System for Drawing Shapes using C#
Class Time
- Homework Discussion
- Visual Studio Tip of the Day: Vertical Selection + Editing
it gets even better thanks to Karel’s tip 💡 Multi-line and multi-cursor editing - Some Key WPF Concepts
- A Dependency Property is a property whose value depends on multiple sources, such as animation, data binding, styles, or visual tree inheritance. A Dependency Property also has the built-in feature of providing notification when the property has changed. Their values are not stored in the local object but (only changed) properties are stored in a dictionary of key/value pairs which is provided by the DependencyObject class.
- Attached Properties are a special kind of Dependency Properties that are settable on a different object than the one that exposes it. An example of attached property is a StackPanel using DockPanel.Dock=”Top” or a Button using Canvas.Left=”120″.
-
Content Controls are controls that can contain a single item in their Content property. This can of course also be one of the panel controls…
Below are some examples of Content Controls: - Button
- Label
- RadioButton
- Tooltip
- A special type of Content Control is the Headered Content Control
- Examples of other types of controls can be found here
- ItemsControls contain a collection of child objects. The ItemSource or Items property specifies the source collection of child objects.
- 💡 If you specify a value for the ItemsSource property, the Items collection is made read-only and fixed-size, which means that you cannot add items to the collection directly.
- 💡 Example of how to display selected text from both ComboBox and ListBox in a Label:
Below are some examples of ItemsControls:
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (myLabel != null) { // Selector is a base class of both ComboBox and ListBox // Both ComboBoxItem and ListBoxItem derive from ContentControl myLabel.Content = ((sender as Selector)?.SelectedValue as ContentControl)?.Content.ToString(); } }
👓 WPF101 > ResourcesDemo
- Defining Resources by Using XAML
- Defining Resources Programmatically
- Referencing Resources in XAML
- reference as StaticResource
- reference as DynamicResource
The most common markup extensions used in WPF programming are those that support resource references (StaticResource and DynamicResource)
💡 you could also paint using a Gradient Brush
👓 WPF101 > StylesDemo
You can think of a style as a convenient way to apply a set of property values to more than one element
Lesson 05 Thursday July 2nd (08:30 – 12:00)
Homework to finish before this lesson
Complete the following assignment using Visual Studio 2019:
Exercise: Creating a Visual Solar System using WPF
Class Time
- Homework Discussion
- Visual Studio Tip of the Day: Run To Cursor
- Control Templates
👓 WPF102 > ControlTemplatesDemo
👓 WPF102 > SeparateControlTemplateDemo - Template Binding
- Control Templates for Items Controls
👓 WPF102 > ControlTemplateForItemsControlDemo
💡 How to Extract Default Control Templates In Visual Studio - Routed Events
👓 WPF102 > TunnelingAndBubblingDemo
👓 WPF102 > RoutedEventsDemo - Commands
- Introduction to Commands
- Using Commands
- Implementing a Custom Command
👓 WPF102 > CommandPatternDemo - Data Binding
- Introduction
- Binding Markup Extension
- Data Binding Modes
👓 WPF102 > BindingToControlsDemo
💡 In general, user-editable control properties, such as those of text boxes and check boxes, default to two-way bindings, whereas most other properties default to one-way bindings. - OneWay
- TwoWay
- OneWayToSource
- OneTime
By setting the Template property to another instance of a Control Template, you can completely replace the appearance (visual tree) of a control.
In many cases, Control Templates give you sufficient flexibility so that you do not have to implement your own Custom Controls
Routed events are events that can invoke handlers on multiple listeners in an element tree, instead of invoking them only on the object that raised the event. This behavior is largely invisible if you are handling an event on the element where it is raised, but becomes powerful if you use any of these scenarios: defining common handlers at a common root, compositing your own control, or defining your own custom control class.
Data Binding enables a clean separation of business logic from UI
Lesson 06 Tuesday July 7th (08:30 – 12:00)
Homework to finish before this lesson
Complete parts 6 and 7 of our solar system assignment:
Exercise: Creating a Visual Solar System using WPF
Class Time
- Homework Discussion
- Visual Studio Tip of the Day: C# Interactive Window
- DataContext
- Specify the Binding Source using C# (via Code Behind)
👓 WPF103 > BindingToSingleObjectDemo - Specify the Binding Source using XAML
👓 WPF103 > BindingToSingleObjectDemoXAMLTwoStep
👓 WPF103 > BindingToSingleObjectDemoXAMLOneStep - The UpdateSourceTrigger Property
👓 WPF103 > UpdateSourceTriggerDemo - Property Change Notification
- The INotifyPropertyChanged interface
👓 WPF103 > BindingToSingleObjectDemoINPC - Converting Data
- ValueConverter
👓 WPF103 > ValueConverterDemo - MultiValueConverter
👓 WPF103 > MultiValueConverterDemo
An IMultiValueConverter is really just an IValueConverter that accepts an array of objects as input and outputs a converted object
(a list of built-in Value Converters)
Lesson 07 Tuesday July 14th (08:30 – 12:00)
Homework to finish before this lesson
Complete parts 8 and 9 of our solar system assignment:
Exercise: Creating a Visual Solar System using WPF
Class Time
- Homework Discussion
- Visual Studio Tip of the Day: Clipboard history
- UnsetValue
The DependencyProperty class contains a single property called UnsetValue. This is a read-only property and is used instead of null or a default to indicate that the property is registered but that the property system has not yet assigned a value to the property. ValueConverters are advised to handle anticipated problems by returning DependencyProperty.UnsetValue as also shown in these books: - StringFormat
👓 WPF104 > StringFormatDemo - Detecting Data Binding Errors
- Debugging Data Bindings
examples present in 👓 WPF104 > StringFormatDemo - How To Debug Data Binding Issues in WPF
👓 WPF104 > App.xaml.cs - Validating Data
- Implement Binding Validation
👓 WPF104 > BindingValidationDemo - Implement Validation Logic on Custom Objects
👓 WPF104 > IDataErrorInfoImplementationDemo
Validation occurs before conversion, so your validation logic must be written against the unconverted value
Lesson 08 Tuesday July 21th (08:30 – 12:00)
Homework to finish before this lesson
Complete parts 10, 11, 12, 13, 14, 15, 16 and 17 of our solar system assignment:
Exercise: Creating a Visual Solar System using WPF
Class Time
- Homework Discussion
- Visual Studio Tip of the Day: Searching inside Visual Studio plus Navigate/GoTo (Ctrl+,)
- Binding to Collections
- 👓 WPF105 > SelectedValuePathDemo
- 👓 WPF105 > BindingToACollectionDemo
- Observable Collections
💡 ObservableCollection(T) implements INotifyCollectionChanged to provide notifications when items are added or removed or the whole collection is changed. When a control is bound to an ObservableCollection, WPF automatically adds a CollectionChanged event handler to that ObservableCollection’s events.
💡💡 Each object in the collection must implement INotifyPropertyChanged. Otherwise changes to individual object properties are not broadcasted.
👓 WPF105 > ObservableCollectionDemo
👓 WPF105 > ObservableCollectionDemoXAML - 💡 this demo also uses a so-called ObjectDataProvider
- Collection Views
💡 A Collection View is a wrapper around a collection that enables sorting, filtering and grouping without manipulating the underlying source collection. All collections have an associated default collection view. The binding engine always accesses the collection by using the associated view.
👓 WPF105 > CollectionViewDemo - Data Templates
👓 WPF105 > DataTemplateComboBoxDemo
The ListView control makes heavy use of DataTemplates.
💡 the _Starter.xaml file in every 👓 WPF10x demo solution contains both a Collection View and a Data Template - Showing Sample Data while Designing
- Sample data on the design surface and for prototyping
- Creating Sample Data from a Class
👓 WPF105 > DesignTimeDataDemo - Appendix: Summary of WPF Class Hierarchy
An ObjectDataProvider allows us to specify a method name, pass arguments and invoke it from XAML
7. The Model-View-ViewModel (MVVM) Software Architectural Pattern
- What Wikipedia has to say
- Introducing the MVVM Pattern
- Getting started with MVVM WPF
- Commands Revisited
- RelayCommand by Josh Smith
👓 MVVMExamples > ViewDemoUsingRelayCommand
👓 MVVMExamples > ViewDemoReceivingCollectionView - DelegateCommand as seen in some MVVM toolkits
👓 MVVMExamples > ViewDemoUsingDelegateCommand - RelayCommand vs DelegateCommand
- A more complete MVVM Example
👓 NorthwindTradersMVVM - the NorthwindTradersMVVM Demo – Notes, Tips & Tricks document
- including some basic Unit Tests
The name of your Unit Test Method should consist of three parts:
- the name of the method being tested
- the scenario under which it is being tested
- the expected behavior when the scenario is invoked
💡 some examples are:
- Withdraw_ValidAmount_ChangesBalance()
- Withdraw_AmountMoreThanBalance_Throws()
- Add_SingleNumber_ReturnsSameNumber()
- Add_MaximumSumResult_ThrowsOverflowException()
Fundamental equation of MVVM: View.DataContext = ViewModel
also called ‘Marrying the View and the ViewModel’
All user controls that implement the ICommandSource interface (e.g. Buttons, MenuItems) support a Command property that will be invoked when the control’s default action occurs.
Commands are simply objects that implement the ICommand interface. Or, put another way, Commands are messages from the View to your View Model
Lesson 09 Tuesday July 28th (08:30 – 12:00)
Homework to finish before Tuesday September 1st, 2020 (09:00 CEST)
Complete the final assignment: Exercise: Final Assignment
Class Time
8. Introduction to Databases and SQL
9. How to Design a Relational Database
10. Implementing a database using Microsoft SQL Server 2014
💡 in case of error message “Saving changes is not permitted”
11. Perform Create/Read/Update/Delete (CRUD) Operations on SQL Server
- Writing Provider-dependent code using classes from the System.Data.SqlClient namespace
- ADO.NET Framework Data Providers
- SqlConnection
- SqlCommand
- SqlDataReader
👓 EverythingDatabase > ADONET_SQLClasses > SyncSelectDemo
👓 EverythingDatabase > ADONET_SQLClasses > AsyncSelectDemo
👓 EverythingDatabase > ADONET_SQLClasses > AsyncInsertDemo
💡 using statement - Writing Provider-independent code using DbProviderFactories
- Factory Model Overview
- Obtaining a DbProviderFactory
- DbConnection, DbCommand and DbException
👓 EverythingDatabase > ADONET_DbProviderFactories > AsyncSelectDemo
Microsoft’s implementation of an Object-Relational Mapping (ORM) framework (since August 2008)
Final Lesson 10 Tuesday August 4th (08:30 – 12:00)
Class Time
👓 BreakpointsDemo
⧉ this figure illustrates the choices in Visual Studio
💡 server names: (localdb)\MSSQLLocalDB or (local)\SQLEXPRESS
💡 Install latest version (now 6.4.4): Install-Package EntityFramework
💡 Logging and intercepting database operations
- Database First: EF Designer from database
- Creating an Entity Data Model (EDM)
- Relationships between Entities
👓 EverythingDatabase > EF_Designer_from_database - Database First: Code First from database
- Code First targeting an Existing Database
- Code First Migrations with an existing database
👓 EverythingDatabase > Code_First_from_database - Model First: Empty EF Designer model
- Entity Framework – Model First Approach
👓 EverythingDatabase > Empty_EF_Designer_model - Code First: Empty Code First model
- What is Code-First
- EF Code-First Example
- Code-First Conventions
- Database Initialization
- Database Initialization Strategies
- Configure Domain Classes
If your database schema changes right-click on the designer surface of the EDMX designer and click [Update Model From Database…]
If your database schema changes you can either manually edit the classes or perform another reverse engineer to overwrite the classes.
👓 EverythingDatabase > Empty_Code_First_model
12. Language-Integrated Query (LINQ)
- Asynchronous Querying and Saving using Entity Framework
- LINQ Tutorial
- Language Integrated Query (LINQ)
- Query Syntax and Method Syntax in LINQ
- JOINing with LINQ
A behavior encapsulates functionality into a reusable component that can be attached to View elements. Behaviors keep the MVVM pattern intact.
💡 You can also use an Attached Property to provide a service, which is often referred to as Attached Behavior
- Attached Behavior
👓 WPF106 > AttachedBehaviorDemo - Blend Behavior
- Since 2018 XAML Behaviors for WPF is available as NuGet package
👓 WPF106 > BlendBehaviorDemo
👓 WPF106 > AnotherBlendBehaviorDemo
👓 WPF106 > StoryboardAnimationDemo
Blend Behaviors are meant to give interaction designers more flexibility to design complex user interactions without writing any code.
since .NET 2.0 (2006)
- BackgroundWorker Class Sample for Beginners
- WPF Multithreading: Using The BackgroundWorker And Reporting The Progress To The UI
- Backgroundworker in MVVM
- BackgroundWorker Component and MVVM
- BackgroundWorker in WPF with MVVM / ICommand Pattern
👓 WPF106 > BackgroundWorkerMVVMDemo
since .NET 4.0 (2010)
- Task.Run vs BackgroundWorker
- Async in 4.5: Enabling Progress and Cancellation in Async APIs
👓 WPF106 > TaskRunVersusBackgroundworkerDemo
👓 WPF106 > TaskRunMVVMDemo
- System.ComponentModel.DataAnnotations Namespace
- Utilizing INotifyDataErrorInfo in a WPF MVVM app
- Creating a custom Validation Attribute
👓 NorthwindTradersMVVM > EmployeeWrapper & ValidatableBindableBase & EmployeeCustomValidationAttributes
- Collaborative working
- Ease of testing
- Ease of maintainability
- Transparent Communication
In the Microsoft solution stack, the binder is a markup language called XAML
recommended book about design patterns in general: Head First Design Patterns
👓 ActionFuncPredicateDemo