1. Trang chủ
  2. » Công Nghệ Thông Tin

windows vista for developers delivery guide phần 8 pptx

21 248 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. © 2006 Microsoft Corporation. All rights reserved. Microsoft, Microsoft Press, Aero, BizTalk, ClearType, Expression, IntelliSense, Internet Explorer, MSDN, MSN, Segoe, Tahoma, Visual Basic, Visual C#, Visual Studio, Visual Web Developer, Windows, Windows Media, Windows Server, Windows Vista, and WinFX are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Session 3: Introducing Windows Presentation Foundation 1 Developing Windows Presentation Foundation Applications Introduction Microsoft® Windows® Presentation Foundation provides a new model and tools for developers to build client applications that combine advanced UI elements and provide easy access to content from a variety of sources. This session provides an overview of how to create applications by using Windows Presentation Foundation. Objectives After completing this section, you will be able to: • Describe Windows Presentation Foundation. • Explain XAML. • Create applications by using XAML. • Create a Windows Presentation Foundation application. • Manage windows in XAML. • Navigate application pages in XAML. • Build XAML browser applications. • Create rich 2-D and 3-D content. • Use data binding in Windows Presentation Foundation. 2 Session 3: Introducing Windows Presentation Foundation Introducing Windows Presentation Foundation The Microsoft Windows Presentation Foundation provides the foundation for building applications in Microsoft Windows Vista™, blending together application UI, documents, and media content, while exploiting the full power of your computer. Windows Presentation Foundation is exposed through the Microsoft .NET Framework. Windows Presentation Foundation consists of: • A display engine that takes full advantage of modern graphics hardware. • An extensible set of managed classes that developers can use to create rich, visually stunning applications. • Extensible Application Markup Language (XAML), which enables developers to use an XML-based model to declaratively manipulate the object model. Windows Presentation Foundation is based on the following design principles: • Integration of various content sources into a single model. Windows Presentation Foundation provides a single model that can be used to manipulate content from a variety of media sources, document sources, and user interface sources and allows seamless integration of content within a single application. You can use the same constructs for animation, data binding, and styling regardless of whether you are targeting 2-D, 3-D, or text content. • Use of vector-based graphics. The composition engine is vector-based, allowing for scaling of all output to match the resolution of a specific machine. Session 3: Introducing Windows Presentation Foundation 3 • Support for declarative programming. The use of XAML allows applications to parse and manipulate UI logic at run time for dynamic workflow scenarios. Furthermore, the XAML/code-behind model embodied in Windows Presentation Foundation allows designers and developers to work collaboratively on client application design and development. • Easy deployment. Web-browser applications run from within Microsoft Internet Explorer®, either occupying the entire window or fitting in an inline frame. Stand- alone applications are locally installed via ClickOnce or MSI technologies. • Document life-cycle options. Windows Presentation Foundation introduces a new set of document and print technologies. Powerful 3-D graphics hardware that is now standard in most computers is today under- utilized for most applications. The Windows Presentation Foundation sets out to take full advantage of these capabilities as a platform for building rich, immersive, user experiences. 4 Session 3: Introducing Windows Presentation Foundation What Is XAML? XAML (pronounced “zamel”) is a new declarative language for creating application user interfaces. It offers a wealth of new controls and elements with capabilities such as forms development, animation, and rendering of 2-D and 3-D graphics. When a developer creates an application in Windows Presentation Foundation, most of the code is written and implemented in XAML. XAML code must be well-formed XML, be saved in a file with the .xaml extension, and have a namespace that maps to XML namespaces. XAML provides the following benefits: • Faster and easier application implementation. Markup-based interfaces are quick to build and are easily modifiable. They require less code than traditional structured programming. • Easier to localize. Because XAML separates the user interface from the application logic, it is easier to localize the user interface. This also gives the ability for developers to modify application logic without affecting the user interface. Session 3: Introducing Windows Presentation Foundation 5 • Familiar development environment. Developers with experience using HTML or other Web-oriented markup languages will find XAML a familiar environment for developing applications. • Third-party support. XAML can be developed in many different development tools, which offers third-party developers opportunities to create applications by using a variety of visual tools. • Extensible. Using object-oriented programming techniques, developers can extend XAML by creating custom controls, elements, and functionality. • No performance penalty. With XAML, there is no performance penalty because XAML is an XML-based representation of the object model. 6 Session 3: Introducing Windows Presentation Foundation Programming with XAML XAML is the preferred way to create a UI in the Windows Presentation Foundation programming model because it enables you to separate UI definition from logic. It also enables you to integrate code by using code-behind files that are joined to the markup through partial class definitions. For simple cases, you can also specify inline code. Every XAML tag corresponds directly to a .NET Framework class whose properties are controlled through the use of XML attributes. For example, the <Button> tag corresponds directly to the System.Windows.Controls.Button class. Each XAML file includes the following elements: • Root element. As with all well-formed XML files, XAML files must have one root tag. When creating the XAML file, use a root element such as a DockPanel or Canvas that can support a content model so that you can add child elements or other content to it or an element such as Window or Page that is part of the application model. The root element contains Web links references to two of the schemas used by XAML files. These schemas are available at: http://schemas.microsoft.com/winfx/ 2006/xaml/presentation and http://schemas.microsoft.com/winfx/2006/xaml. These schemas contain the definitions of graphical elements represented by WPF and often have a corresponding object associated with them. Session 3: Introducing Windows Presentation Foundation 7 • Properties. XAML properties that are expressed as attributes enable you to add features to object element tags. Often, the properties that appear as XAML attributes on an element are inherited from base classes. For example, the Background property is not an immediately declared property on the Button class but is instead inherited from the base Control class. • Name property. Many XAML elements support a Name property. This property is particularly important because it allows you to reference a particular element from code-behind when that element was originally created from XAML markup. The following code illustrates a simple XAML file: <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Button Name ="MyButton" Background ="Blue">Hello World!</Button> </Canvas> 8 Session 3: Introducing Windows Presentation Foundation Demonstration 1: Writing and Building a XAML Application In this demonstration, you will see how you can write and build a XAML application. Key Points The key points of this demonstration are: • Every XAML file includes some core elements. • You can use a variety of tools to create a XAML application, including XamlPad and Microsoft Visual Studio® 2005. Session 3: Introducing Windows Presentation Foundation 9 Creating a Windows Presentation Foundation Application You can create a WPF application by using a code-behind file or by using inline code. Most applications consist of both XAML and code, such as Microsoft Visual Basic® or Microsoft Visual C#®, in a code-behind file. As a best practice, you should avoid or limit the use of inline code. Using the code-behind model When you use a code-behind model, the code for the application is contained within a class file separate from the XAML file that displays the user interface. This model is similar to the code-behind model used with Microsoft ASP.NET. The model allows a clean separation of the XAML content from the application code. The root XAML element in an XAML file identifies where the application expects to find the code-behind file when it compiles. The root element specifies a namespace and class as its x:Class attribute value. [...]... Introducing Windows Presentation Foundation Managing Windows Windows Presentation Foundation applications typically have at least one and sometimes several windows Windows are used for a variety of purposes, including hosting graphical UIs, displaying graphics or text information, and handling user interaction The Windows Presentation Foundation Application class provides basic support for windows In... Content Windows Presentation Foundation provides advanced drawing and animation features, features that were previously available only from specialized libraries such as Microsoft Windows Graphics Device Interface (GDI) and Microsoft Windows GDI+ Windows Presentation Foundation now offers integrated support for multimedia, vector graphics, animation, and content composition, making it easy for developers. .. Can specify only three properties: Title, Height, and Width Can specify all properties New windows Can launch only pop-up elements, Can launch additional windows and and they must stay within the window dialog boxes border 14 Session 3: Introducing Windows Presentation Foundation Navigating Application Pages The Windows Presentation Foundation framework provides you with a powerful and flexible way to... be determined at run time from user feedback or external data or you need to navigate a hierarchy of information Although structured navigation can be used for stand-alone applications, it is typically used for relatively short applications that are called by larger applications This type of program guides users through complex procedures in which the next step in the procedure is often not determined... and load the next page, usually called the target page With Windows Presentation Foundation, you can use one of several techniques to navigate from one page to the next • Navigate to a specified URI • Navigate to a specified page object • Navigate forward or backward in the journal Session 3: Introducing Windows Presentation Foundation 15 For example, you can navigate to a new XAML page by using the... of HTML-based applications, XAML browser applications have access to the rich UI features of the Windows Presentation Foundation runtime For the most part, developing a XAML browser application is a matter of standard Windows Presentation Foundation programming and is similar to developing applications for installation Working with Internet Explorer security zones XAML browser applications need to... zone permission set The requirements include: • Use only the subset of Windows Presentation Foundation elements that are compatible with Internet zone permissions • You cannot launch additional windows or dialog boxes You can use pop-up elements, but they must stay within the bounds of the window’s border 18 Session 3: Introducing Windows Presentation Foundation • Obey Internet zone restrictions on... extension • A deployment manifest This file contains the information that ClickOnce uses to deploy the application and has the xbap extension You deploy XAML Browser Applications from a server with Microsoft Internet Information Services (IIS) version 5 or later It is not necessary to have the Windows Presentation Foundation runtime on the server to deploy Windows Presentation Foundation applications from it... window to MainWindow Application hosting and window management You can compile Windows Presentation Foundation applications to run as a XAML browser application or a Windows application These two hosting scenarios impose different requirements for window use as shown in the following table Requirement XAML Browser Application Windows Application Hosting Can run only in the browser Can run only in a stand-alone... you do not need to implement a message pump or window procedure The Application object maintains a collection of references to the windows in your application By default, closing the last window shuts down the application In Windows Presentation Foundation, you can represent windows by using one of these three objects: • Window object Supports core window functionality • NavigationWindow object Extends . Introducing Windows Presentation Foundation Managing Windows Windows Presentation Foundation applications typically have at least one and sometimes several windows. Windows are used for a variety. Segoe, Tahoma, Visual Basic, Visual C#, Visual Studio, Visual Web Developer, Windows, Windows Media, Windows Server, Windows Vista, and WinFX are either registered trademarks or trademarks of Microsoft. Use data binding in Windows Presentation Foundation. 2 Session 3: Introducing Windows Presentation Foundation Introducing Windows Presentation Foundation The Microsoft Windows Presentation

Ngày đăng: 14/08/2014, 02:22