C C T B H P N

Lecture #15 - Windows Presentation Foundation

Concepts and Example Code

Web Resourses:

Content:

This lecture introduces Windows Presentation Foundation (WPF), a Graphical User Interface technology that replaces WinForms. Its programming model seems, at first, to be similar to the WinForms model, but in fact its technology is a radical departure from all prior Microsoft GUI frameworks.
  1. The Syllabus describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Project #1, Project #2, Project #3, Project #4, Project4HelpF2018
  3. Projects:

    Project #2, Project #3, Project4HelpF2018, CsMessagePassingComm classes, CsMessagePassingComm activities
  4. Project #4 Help:

    Remember that you need to run Visual Studio as Administrator for all WCF Projects.
  5. WPF Presentation

  6. Demo code samples

    Basic WPF Demos
    The design-time editor will give you a positioned layout which does not have anchor properties. You can fix that by removing height, width, horizontalalignment, and verticalalignment properties, as shown in this demo. When you run the code you see that the title, listbox, and button are anchored just the way you would want them to be.
    Demo Panels
    Demonstrate behavior of the major panels, e.g., Canvas, DockPanel, Grid, StackPanel, and WrapPanel. Lab Manager Prototype
    Illustrates the kinds of sophisticated user interfaces that WPF supports. Routed Event Demo
    Demonstrates event bubbling on the Xaml parse tree. Attached Properties Demo
    WPF has a very sophisticated property system that supports attaching properties to UIElements that don't define them, illustrated here, and property change notification presented in the Advanced Demos. Triggers Demo
    Triggers provide a way of binding to UI events. There are other ways to do the same thing, so I don't use them much.
    WPF Controls
    A demonstration of several of the WPF control types - this is intended to illustrate how your application communicates with controls.
    Data Template Demo
    Data Templates are a way of customizing the way WPF controls present their data. UserControl Demo
    UserControls are simply composite controls sitting on a form-like substrate. Demo GUI using UserControls for Tabbed display
    Illustrates how to factor Xaml into some nearly reusable chunks. Control Template
    Control Templates let you change the way a WPF control renders itself. Bar Chart Demo
    Bar Chart is a very simple drawing demonstration. WPF with all Code
    You can create a WPF application without any Xaml. This shows you how. Embedded code in Xaml
    This example by Charles Petzold shows how to combine Xaml and C# code in a single file.

    Advanced Demos

    Change Notification
    Illustrates how your applications can use property change notification.
    Dispatcher Demo
    Child threads must not directly manipulate their parent's window. Instead, they are expected to Dispatch a delegate for the operation they want to execute to their parent's thread. This is illustrated here. Message Hook
    WPF applications have an underlying message loop and you can intercept messages in that loop with a Message Hook. Custom Element Demo
    WPF is so flexible that you can even define your own UIElement. You probably won't need to do that since the individual elements are easy to customize.

    Data Binding

    MSDN Presentation - WPF data binding
    Data binding cheat-sheet
    {Binding}
  7. Microsoft WPF Samples
  8. WPFpedia.com Samples
  9. Flow Document References:

  10. WPF Tutorials:

  11. UI and Enterprise Patterns