When Microsoft Releases Windows Vista, the New Operating System Will Support Applications That Employ Graphics Now Used by Computer Games-Clear, Stunning and Active
Total Page:16
File Type:pdf, Size:1020Kb
XAML in a Nutshell By Lori A. MacVittie ............................................... Publisher: O'Reilly Pub Date: March 2006 Print ISBN-10: 0-596-52673-3 Print ISBN-13: 978-0-59-652673-3 Pages: 302 Table of Contents | Index When Microsoft releases Windows Vista, the new operating system will support applications that employ graphics now used by computer games-clear, stunning and active. The cornerstone for building these new user interfaces is XAML ("Zammel"), the XML-based markup language that works with Windows Presentation Foundation (WPF), Vista's new graphics subsystem. An acronym for Extensible Application Markup Language, XAML offers a wealth of new controls and elements with exciting capabilities, including animation and rendering of 3D graphics. Windows developers are already jazzed by the possibilities of using XAML for fixed and flow format documents like PDF and HTML, 2D and 3D vector-based graphics, form development, animation, audio and video, transparent layering, and a lot more. Many feel that XAML will eliminate the need for multiple file formats or plug-ins (read: Flash), while lowering development costs and reducing time to market. The problem is, most developers don't know XAML. While it is fairly easy to understand, you still need a quick guide to bring you up to speed before Vista's release, and that's where this book's simple, no nonsense approach comes in. XAML in a Nutshell covers everything necessary to design user interfaces and .NET applications that take advantage of WPF. Prerequisites such as Microsoft's new unified build system, MSBuild, and core XAML constructs and syntax-including shortcuts-are all presented with plenty of examples to get you started. The Core XAML Reference section lets you dig even deeper into syntax rules and attributes for all XAML elements with a series of quick-reference chapters. This section divides XAML elements into logical categories of elements, controls, shapes and geometry, layout, animations, and transformations for easy reference. XAML in a Nutshell helps you learn, firsthand, how to use this XML-based markup language to implement the new generation of user interface graphics. As one reviewer noted, "Strong code examples and an efficient, conversational style take the tedium out of learning XAML and make the subject understandable-even interesting." XAML in a Nutshell By Lori A. MacVittie ............................................... Publisher: O'Reilly Pub Date: March 2006 Print ISBN-10: 0-596-52673-3 Print ISBN-13: 978-0-59-652673-3 Pages: 302 Table of Contents | Index Copyright Preface Who Should Read This Book What This Book Covers Organization Conventions Used in This Book Using Code Examples Comments and Questions Safari® Enabled Acknowledgments Part I: Introducing XAML Chapter 1. Introducing XAML Section 1.1. The Benefits of XAML Section 1.2. What XAML Is Not Section 1.3. XAML Development Resources Chapter 2. Getting Started with XAML Section 2.1. XAML Prerequisites Section 2.2. Defining XAML Applications Section 2.3. Building XAML Applications Section 2.4. XAML Applications and Visual Studio Part II: XAML Concepts Chapter 3. The Basics of XAML Section 3.1. Core XAML Syntax Section 3.2. Elements Section 3.3. Attributes Section 3.4. Attached Properties Section 3.5. Binding Properties Section 3.6. codebehind Chapter 4. Layout and Positioning Section 4.1. StackPanel and DockPanel Section 4.2. Using Width and Alignment Section 4.3. Margins and Padding Section 4.4. Grid Section 4.5. Absolute Positioning Chapter 5. Resources Section 5.1. Using Resources Section 5.2. Using Styles Section 5.3. Triggers Chapter 6. Storyboards and Animations Section 6.1. Storyboards Section 6.2. Controlling Animations Section 6.3. Animation Using Key Frames Part III: Core XAML Reference Chapter 7. Elements Bold Brush Color Figure Floater Frame GradientStop Image ImageBrush Inline Italic Label LinearGradientBrush LineBreak List ListItem Paragraph Pen RadialGradientBrush Section SolidColorBrush TextBlock TextDecoration TextDecorationCollection TextEffect Thickness Underline Chapter 8. Controls Section 8.1. Base Control Reference Section 8.2. Common Event Reference Section 8.3. Core Control Reference Chapter 9. Shapes and Geometry ArcSegment BezierSegment CloseSegment CombinedGeometry DrawingBrush DrawingGroup Ellipse EllipseGeometry GeometryDrawing GeometryGroup ImageDrawing Line LineGeometry LineSegment Path PathFigure PathFigureCollection PathGeometry PathSegmentCollection Point Point3D PointCollection PolyBezierSegment Polygon Polyline PolyLineSegment PolyQuadraticBezierSegment QuadraticBezierSegment Rect Rect3D Rectangle RectangleGeometry StartSegment Chapter 10. Layout Border Canvas ColumnDefinition DashStyle DockPanel FixedDocument FlowDocument Grid PageContent Panel RowDefinition Setter StackPanel Style Table TableCell TableColumn TableRow Trigger Chapter 11. Animations and Transformations AnimationTimeline BooleanKeyFrame CharKeyFrame ColorAnimation ColorKeyFrame DecimalAnimation DecimalKeyFrame DoubleAnimation DoubleAnimationUsingPath DoubleKeyFrame Int16KeyFrame Int32KeyFrame Int64KeyFrame KeySpline Matrix MatrixAnimationUsingPath MatrixKeyFrame MediaTimeline ParallelTimeline PointAnimationUsingPath Point3DKeyFrame PointKeyFrame RectAnimation Rect3DKeyFrame RectKeyFrame RotateTransform Rotation3D Rotation3DKeyFrame ScaleTransform SetterTimeline SkewTransform SizeAnimation Size3D Size3DKeyFrame SizeKeyFrame StringKeyFrame ThicknessKeyFrame Timeline TranslateTransform VectorAnimation VectorKeyFrame Vector3DKeyFrame Vector Vector3D Chapter 12. Events Section 12.1. Routing Strategies Section 12.2. Event Argument Reference Section 12.3. Event Reference Part IV: Appendixes Appendix A. System.Windows.Controls Appendix B. System.Windows.Documents Appendix C. System.Windows.Shapes Appendix D. System.Windows Appendix E. System.Windows.Media Appendix F. System.Windows.Input.ApplicationCommands Appendix G. Predefined Colors Appendix H. XAML Interface in Code About the Author Colophon Index Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Editor: Jeff Pepper Production Editor: Matt Hutchinson Copyeditor: Rachel Monaghan Proofreader: Matt Hutchinson Indexer: Ellen Troutman Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: Robert Romano, Jessamyn Read, and Lesley Borash Printing History: March 2006: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarksof O'Reilly Media, Inc. The In a Nutshell series designations, XAML in a Nutshell, the image of a kudu, and related trade dress are trademarks of O'Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 0-596-52673-3 [M] Preface Windows Vista is on its way, and with it comes a brand-new mechanism for defining user interfaces. XAML is one of many new technologies appearing in Windows Vista and promises to be a pervasive part of core Windows programming across a variety of yet-to-be-introduced Windows frameworks. XAML completely removes the need for user-interface designers to understand code. Third-party visual layout applications can now generate valid XAML for use in building sophisticated Windows Vista applications. The Windows Presentation Foundation (WPF), and therefore XAML, offer many sophisticated user- interface features that are not available in other declarative markup languages such as HTML or XUL. Scaling and rotation of both text and graphics, animation, and extensibility are all core parts of WPF and accessible to XAML developers. While HTML was developed primarily for displaying text and graphics on the Web, XAML's primary target is native Windows applications (although it can also target web-based deployments). The close relationship between runtime objects and the elements in a XAML file make XAML an easy choice for user-interface design on the Windows platform. It offers the means to create rich, or "smart," clients that act more like a full-featured interface than a web-based application. XAML can be used to design user interfaces without the need for code, or it can be used in conjunction with supported .NET languages such as C# and VB.NET. XAML is the preferred method of developing interfaces for applications on the Windows Vista platform because its powerful features allow developers to create interfaces that go above and beyond traditional interface design. XAML and the WPF open up endless possibilities for exciting new user interfaces, and this book will provide an understanding of the language and the framework upon which those interfaces are developed. Who Should Read This Book This book is intended for both .NET developers and user-interface designers