Windows Presentation Foundation

Similar documents
DOT.NET MODULE 6: SILVERLIGHT

Introduction. Part I: Silverlight Fundamentals for ASP.NET Developers 1

Course 3D_WPF: 3D-Computer Graphics with C# + WPF Chapter C4: The complete code of Sphere

Course 3D_WPF: 3D-Computer Graphics with C# + WPF Chapter C4: Sphere

Windows Presentation Foundation. Jim Fawcett CSE687 Object Oriented Design Spring 2018

Beginning Silverlight 5 in C #

Windows Presentation Foundation for.net Developers

Course 3D_WPF: 3D-Computer Graphics with C# + WPF Chapter C3: Dice

DOT NET SYLLABUS FOR 6 MONTHS

WPF. Source Module 01: Lesson1

Introduction p. 1 Who Should Read This Book? p. 2 Software Requirements p. 3 Code Examples p. 3 How This Book Is Organized p. 4 Conventions Used in

CS3240 Human-Computer Interaction Lab Sheet Lab Session 2

PART I: INTRODUCTION TO WINDOWS 8 APPLICATION DEVELOPMENT CHAPTER 1: A BRIEF HISTORY OF WINDOWS APPLICATION DEVELOPMENT 3

Road Map for Essential Studio 2010 Volume 1

SHAPES & TRANSFORMS. Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ.

Windows Presentation Foundation Programming Using C#

LAYOUT. Chapter 3 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

Programming Windows, Sixth Edition

What s New Essential Studio User Interface Edition, 2011 Volume 4

XAML Designer for.net 3.5

Introduction p. 1 Getting Started Hello, Real World p. 9 Creating, Deploying, and Profiling an App p. 9 Understanding the App Package p.

Controls WPF. Windows Programming. Lecture 8-1. Krzysztof Mossakowski Faculty of Mathematics and Information Science

Road Map for Essential Studio 2011 Volume 4

Generating Vectors Overview

COPYRIGHTED MATERIAL. viii. About the Authors...v Acknowledgments...vii Introduction...xxvii

Index. Windows 10 running, 199 suspended state, 199 terminate apps,

BASICS OF MOTIONSTUDIO

CPSC Tutorial 5 WPF Applications

CHAPTER 1: INTRODUCING C# 3

XAML. Chapter 2 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon Understanding XAML

10/18/2010 ' ( )* +, ('')* +, !" #$ % !""#$

SNOWFLAKES PHOTO BORDER - PHOTOSHOP CS6 / CC

ROUTED EVENTS. Chapter 5 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon

James Foxall. Sams Teach Yourself. Visual Basic 2012 *24. Hours. sams. 800 East 96th Street, Indianapolis, Indiana, USA

Windows Presentation Foundation (WPF)

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6

Workspace Desktop Edition Developer's Guide. Migrate Custom Applications from 8.1 to 8.5

ViewONE User Manual. Genazim. The Friedberg Geniza Project. Daeja Image Systems. All Rights Reserved.

UI Elements. If you are not working in 2D mode, you need to change the texture type to Sprite (2D and UI)

Paint Tutorial (Project #14a)

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

StickFont Editor v1.01 User Manual. Copyright 2012 NCPlot Software LLC

Vision V sion o n I n n 1975 V sion o n T o T d o a d y A c o c m o pu p t u er e o n o n e v e e v r e y E po p w o er e p e p o e p o l p e

Adobe After Effects Tutorial

move object resize object create a sphere create light source camera left view camera view animation tracks

Creating a T-Spline using a Reference Image

City of La Crosse Online Mapping Website Help Document

Microsoft Visio Working with Shapes

V-BOX Cloud Configuration

Office 2007/2010 Conversion

The American University in Cairo. Academic Computing Services. Word prepared by. Soumaia Ahmed Al Ayyat


Lab 7: Silverlight API

ArcGIS Pro SDK for.net UI Design for Accessibility. Charles Macleod

Installation and Configuration Manual

Creating a Text Frame. Create a Table and Type Text. Pointer Tool Text Tool Table Tool Word Art Tool

Course 2D_WPF: 2D-Computer Graphics with C# + WPF Chapter C1a: The Intro Project Written in XAML and C#

Microsoft CSharp

solidthinking User Interface

How to draw and create shapes

SciGraphica. Tutorial Manual - Tutorials 1and 2 Version 0.8.0

CST242 Windows Forms with C# Page 1

BCIS 4650 Visual Programming for Business Applications

Insight: Measurement Tool. User Guide

10262A VB: Developing Windows Applications with Microsoft Visual Studio 2010

LAB # 2 3D Modeling, Properties Commands & Attributes

HIGH-PERFORMANCE C# DEVELOPMENT FOR RICH-UI DATA- BASE DEVELOPERS

This book was purchased by

Work with Shapes. Concepts CHAPTER. Concepts, page 3-1 Procedures, page 3-5

Programming Training. This Week: Tkinter for GUI Interfaces. Some examples

ADOBE TRAINING CS6 PHOTOSHOP BASICS: EDITING PHOTOS & WORKING WITH TEXT - 1

Reset Cursor Tool Clicking on the Reset Cursor tool will clear all map and tool selections and allow tooltips to be displayed.

ComponentOne. PdfViewer for WPF and Silverlight

Lesson 1: Creating T- Spline Forms. In Samples section of your Data Panel, browse to: Fusion 101 Training > 03 Sculpt > 03_Sculpting_Introduction.

Weather forecast ( part 2 )

Week 6: First XAML Control Exercise

Is image everything?

Chapters and Appendix F are PDF documents posted online at the book s Companion Website (located at

Adobe Flash CS4 Part 4: Interactivity

Recipes4Success. Animate Plant Growth. Share 4 - Animation

INFRAGISTICS WPF 16.1 Service Release Notes December 2016

Customisation and production of Badges. Getting started with I-Color System Basic Light

OpenForms360 Validation User Guide Notable Solutions Inc.

PowerPoint 2016 Building a Presentation

VIEWZ 1.3 USER MANUAL

ITEC185. Introduction to Digital Media

Adobe Animate Basics

1A Windows Presentation Foundation Explained. Rob Layzell CA Technologies

What s New Essential Studio User Interface Edition

CECOS University Department of Electrical Engineering. Wave Propagation and Antennas LAB # 1

Interactive Tourist Map

Word 2003: Flowcharts Learning guide

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

Interface Builders and Interface Description Languages

Patrocinadores. Web Platforms. DEV002 The Microsoft Web Story. Jeff Prosise Cofounder, Wintellect ASP.NET 2.0 ASP.

B.V Patel Institute of Business Management, Computer & Information Technology

GEOCIRRUS 3D Viewer. User Manual: GEOCIRRUS 3D Viewer Document version 1.6 Page 1

Before You Begin. and Visual Basic 1

Introduction Make a plan with tool Rectangle Measurements Toolbar Enter Return Measurements Toolbar Measure Protractor

Advances in MicroStation 3D

Transcription:

Windows Presentation Foundation CS 525 John Stites

Table of Contents Introduction... 3 Separation of Presentation and Behavior... 3 XAML Object Elements... 3 2-D Graphics... 6 3-D Graphics... 9 Microsoft Expression Studio... 11 References... 12 Page 2 of 12

Introduction This document is intended to give a brief overview of the new features contained in the Windows Presentation Foundation (WPF). It describes the overall goal of the WFP application model and shows a few examples of how a WPF application is developed using the built-in controls, 2-D graphics, and 3-D object rendering. Separation of Presentation and Behavior In the traditional ASP programming model, the coding logic and the presentation HTML are intertwined in the same file. This made writing and maintaining the code a cumbersome process that was prone to mistakes. To improve on this programming paradigm, ASP.NET introduced the concept of separating the presentation from behavior by creating the model of a code-behind file. This separated the HTML code, the presentation of the web page, from the application code, which defined the functional logic of the page. The.NET platform, version 3.0, continues this trend by extending the separation concept to forms-based applications, which previously followed the same ASP model of combining the presentation and the logic. In the new model, the presentation of the application is defined using a new language called XAML (pronounced zammel) which is an XML-based language to describe the layout and appearance of objects. The overall application model of using XAML with code-behind as well as all of the services that can be utilized within this model is called the Windows Presentation Foundation, or WPF. XAML Object Elements XAML is an XML-based language used to define objects in an application. It defines their appearance, properties, relationships with other objects, and interactions within the application. Each element in a XAML file will result in a corresponding object being created at runtime. In this way, it is considered a declarative language, declaring the objects up front that will be created. In its simplest form, the layout of a XAML application begins with the topmost object of the document: <Window x:class="windowsapplication.window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Page 3 of 12

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="My Application" Height="200" Width="500" > </Window> <!-- Instantiate contained objects here --> In this example, a Window object is declared with attributes describing the XML namespace for the rest of the document, as well as some default appearance properties like Title, Height, and Width. The namespace declarations tell the object loader which objects to create based on the elements found in the document. The Window element also describes the.net class, WindowsApplication.Window1, that will be used to provide the application logic for the Window. The elements that would appear on the windows form can be declared within the Window element. WPF provides a comprehensive set of controls that can be created within your application. It also provides the means to easily create your own controls if the default ones don t meet your needs. The standard controls are: Category Controls Editing List Selection CheckBox, ComboBox, PasswordBox, RadioButton, RichTextBox, Slider, TextBox ListBox, ListView, TreeView User Information Label, ProgressBar, Popup, ToolTip Action Appearance Button, ContextMenu, Menu, Separator, StatusBar, Thumb, ToolBar Border, BulletDecorator, Decorator, Image, Viewbox Dialog boxes OpenFileDialog, PrintDialog, SaveFileDialog Containers Layout Navigation Expander, GroupBox, RepeatButton, ScrollBar, ScrollViewer, TabControl Canvas, DockPanel, Grid, GridSplitter, Panel, StackPanel, VirtualizingStackPanel, WrapPanel Frame, Hyperlink Documents DocumentViewer, FlowDocumentPageViewer, FlowDocumentReader, FlowDocumentScrollViewer Table 1: Standard UI Controls Page 4 of 12

Using a control can be as simple as declaring it in the XAML document in its proper location: <Button Background="Blue" Foreground="Red" Content="This is a button"/> For this declaration, a button will be created with a blue background and red text stating This is a button : Figure 1: Colored Button Appearance properties can be set on the object to change the way it interacts with its surrounding environment in this case, the window: <Button Content="Click me"> <Button.Margin> <Thickness Left="10" Top="20" Right="10" Bottom="30"/> </Button.Margin> </Button> Which appears as: Page 5 of 12

Figure 2: Formatted Button The application logic contained in the code-behind file determines what happens when the button is clicked. Because the logic is separated from the XAML, it acts independently of the appearance of the button. 2-D Graphics WPF provides new graphics features not previously available to windows developers without resorting to using GDI drawing primitives or interacting directly with the DirectX framework. Out of the box, WPF provides a set of commonly used shapes, such as rectangles and ellipses, which developers can add to their applications using XAML. These vector-drawn 2-D shapes can be programmed using the same code-behind model as the control elements used in the previous section. For instance, an ellipse can be drawn to a form and used as a button element: <Ellipse Fill="Blue" Name="myBlueEllipse" MouseUp="myBlueEllipse_MouseUp" /> When this application is run, the following ellipse is drawn to the window: Page 6 of 12

Figure 3: Ellipse By default, WPF provides the ability to draw the ellipse to the screen. It additionally includes support for input from the user, in this case a mouse click. It automatically creates boundaries for the ellipse object that include only the blue ellipse, not the white portions at the corners. If the user clicks the white portion, nothing happens. Only when the user s mouse pointer enters the blue region and clicks does the MouseUp event occur. When the simple 2-D objects included in the foundation are not enough for the user, custom geometries can easily be created to provide more advanced shapes. By using geometries, developers can create custom lines by setting the start and end points of the line. They can create custom rectangles by specifying the top-left point and the x and y lengths. Or they can create custom ellipses by specifying the center point as well as the x and y radii. For example: <Image Source="sampleImages\Waterlilies.jpg" Width="200" Height="150" HorizontalAlignment="Left"> <Image.Clip> <EllipseGeometry RadiusX="100" RadiusY="75" Center="100,75"/> </Image.Clip> </Image> This example creates an image which clips the edges off outside of the defined EllipseGeometry. The result would look like the following, with the unclipped image on the left and the clipped image on the right: Page 7 of 12

Figure 4: Clipped Image But even these simple shapes have limitations. WPF provides the ability to break more complex shapes into segments that can be drawn individually to compose an overall shape. Developers can use LineSegments, BezierSegments, and ArcSegments, to name a few, to compose more complex shapes. WPF also provides the ability to create brush effects on the shapes and objects created in an application. The following is an example of how different brush objects can be used to change the appearance of objects: Figure 5: Brush Effects Page 8 of 12

All effects shown can be created declaratively using XAML without involving a single line of application code. 3-D Graphics The WPF is built upon the DirectX framework, therefore allowing the developer to create 3-D scenes and graphics. The developer can use the 3-D coordinate space to render any scenes that fit the application s needs. The developer can use Cameras and Projections to change the point of view of the scene for the viewer, as well as illuminate the scene with lighting objects. This can all be done in the same declarative XAML format as the 2-D graphics, giving the developer more control in separating the presentation from the application logic. The developer creates 3-D primitives by describing them using a Mesh Geometry. A 3-D primitive is a collection of vertices that form a single 3-D entity. By describing the primitive, providing a light source and a camera angle, and brushing the primitive, the developer can build up more complex 3-D objects like the following: Figure 6: Rendered 3-D Object This object is described completely using XAML code: Page 9 of 12

<Viewport3D Name="myViewport" > <!-- Add a camera. --> <Viewport3D.Camera> <PerspectiveCamera FarPlaneDistance="20" LookDirection="0,0,1" UpDirection="0,1,0" NearPlaneDistance="1" Position="0,0,-3" FieldOfView="45" /> </Viewport3D.Camera> <!-- Add models. --> <ModelVisual3D> <ModelVisual3D.Content> <Model3DGroup > <!-- Lights, MeshGeometry3D and DiffuseMaterial objects are added to the ModelVisual3D. --> <DirectionalLight Color="#FFFFFFFF" Direction="3,-4,5" /> <!-- Define a red cone. --> <GeometryModel3D> <GeometryModel3D.Geometry> <MeshGeometry3D Positions="{removed for clarity}" Normals="{removed for clarity} TriangleIndices="{removed for clarity} /> </GeometryModel3D.Geometry> <GeometryModel3D.Material> <DiffuseMaterial> <DiffuseMaterial.Brush> <SolidColorBrush Color="Red" Opacity="1.0"/> </DiffuseMaterial.Brush> </DiffuseMaterial> </GeometryModel3D.Material> </GeometryModel3D> </Model3DGroup> </ModelVisual3D.Content> </ModelVisual3D> </Viewport3D> Page 10 of 12

This can all be done using XAML. However, the developer is still free to react to user input, like dragging the image or rotating it by programmatically changing the camera position. In this way, complex interactions, animations, and scenes can be rendered within the WPF application framework. Microsoft Expression Studio With the ability to separate an application s appearance from its logic, Microsoft has created the ability to divide the work between the designers and the developers more cleanly. It has created a suite of tools that let designers create application designs that can then be handed to developers who develop the application logic behind the design. Microsoft Expression lets designers create sophisticated vector assets that can be transferred to developers by way of XAML. That is, a vector-based design can be saved into its equivalent XAML representation that the developer is then free to add application logic to. Developers no longer need to try to re-create visual aspects of an application that a designer created in a non-compatible tool. Instead, they work directly with the output of the designer s efforts. Page 11 of 12

References Microsoft Developer s Network: http://msdn2.microsoft.com/en-us/library/ms742119.aspx http://msdn2.microsoft.com/en-us/library/ms747437.aspx http://msdn2.microsoft.com/en-us/library/aa970268.aspx#controls http://msdn2.microsoft.com/en-us/library/ms747393.aspx http://msdn2.microsoft.com/en-us/library/ms747437.aspx Microsoft Expression Studio http://www.microsoft.com/products/expression/en/expression-studio/default.mspx Wikipedia.org http://en.wikipedia.org/wiki/code-behind http://en.wikipedia.org/wiki/model-view-controller Page 12 of 12