Week 7a - Graphical User Interfaces for C++ Applications
Windows Presentation Foundation and C++\CLI
Synopsis:
This lecture introduces Windows Presentation Foundation (WPF), a .Net Graphical User Interface technology.
Its programming model is relatively simple and very powerful.
We combine this .Net-related material with
C++\CLI, a .Net language that syntactically is close to C++, but builds to managed code. It has the extraordinary
capability to interoperate with native C++ directly, even in the same code file. That's necessary to easily use
WPF's managed code in an application based on C++'s native code.
Builds interface windows using a custom XML markup, called XAML, and C# or C++\CLI event handlers.
Layout model is similar to HTML.
Provides pervasive dependency relationships between graphical elements and bubbling of events.
Supports very complete designer control over the appearance and behavior of each window view.
Runs only on Windows, as a desktop application.
XAML:
A custom XML language where element tags are names of .Net classes, usually placed in a file devoted to markup.
Code behind:
C# or C++\CLI code used for handling user and system events, usually placed in a separate code file.
C++\CLI
A .Net managed language that runs in a Common Language Runtime (CLR) virtual machine and stores its instances in a managed heap,
providing garbage collection, exception handling, and reflection services. C++\CLI code interoperates directly
with native C++ code. C++\CLI code and native C++ may be placed in the same file.
Demo Panels
Illustrates how grid, canvas, dock, stack, and wrap panels work.
Routed Event Demo
Demonstrates event bubbling with Routed Events.
Attached Properties Demo
An example of attached properties used to dock buttons in a window.
Triggers Demo
Illustrates one use of triggers to change a textbox property.
WPF Controls
Shows how several of the most common kinds of controls are used. Includes use of data binding.
Data Template Demo
Data Templates are used to modify how data is displayed in WPF controls.
Control Template
Control templates can be used to modify the presentation of window controls.
Bar Chart Demo
Illustrates using rectangles to build a bar chart where each bar has a tooltip.
WPF with all Code
A WPF application can be built without using XAML. This demo illustrates how.
Advanced Demos
Change Notification Dispatcher Demo Message Hook Custom Element Demo
WPF-Interop
Simple demonstration showing how to interoperate between C++\CLI and native C++, using WPF.
Note that you will be required to do this kind of interoperation for Projects #3 and #4.
Preparation for Synchronous Discussion:
Using one of the tutorials, above, decide how you would layout a Client for Sample Project #4.
Draw a sketch of the UI and be prepared to discuss.
Lecture Take-aways:
The most important things we discussed are:
Windows Presentation Foundation (WPF) presentation