Writing Windows 8 Apps with C# and XAML, First Preview Edition

Total Page:16

File Type:pdf, Size:1020Kb

Writing Windows 8 Apps with C# and XAML, First Preview Edition Programming Windows® SIXTH EDITION Release Preview eBook Writing Windows 8 Apps With C# and XAML Charles Petzold PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2012 Charles Petzold All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. ISBN: 978-0-7356-7176-8 This document supports a preliminary release of a software product that may be changed substantially prior to final commercial release. This document is provided for informational purposes only and Microsoft makes no warranties, either express or implied, in this document. Information in this document, including URL and other Internet website references, is subject to change without notice. The entire risk of the use or the results from the use of this document remains with the user. Unless otherwise noted, the companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted in examples herein are fictitious. 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. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us /IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Acquisitions, Developmental, and Project Editor: Devon Musgrave Technical Reviewer: Marc Young Cover: Twist Creative • Seattle Introduction ......................................................................................................... 9 The Versions of Windows 8 ....................................................................................................................................................... 9 The Focus of This Book ............................................................................................................................................................. 10 The Approach ............................................................................................................................................................................... 12 My Setup ........................................................................................................................................................................................ 13 The Programming Windows Heritage .................................................................................................................................. 13 Behind the Scenes ....................................................................................................................................................................... 16 Errata & Book Support .............................................................................................................................................................. 17 We Want to Hear from You ..................................................................................................................................................... 17 Stay in Touch ................................................................................................................................................................................ 17 Chapter 1: Markup and Code .......................................................................... 18 The First Project ........................................................................................................................................................................... 18 Graphical Greetings .................................................................................................................................................................... 24 Variations in Text ......................................................................................................................................................................... 28 Media As Well .............................................................................................................................................................................. 36 The Code Alternatives ............................................................................................................................................................... 37 Images in Code ............................................................................................................................................................................ 41 Not Even a Page .......................................................................................................................................................................... 43 Chapter 2: XAML Syntax .................................................................................. 45 The Gradient Brush in Code .................................................................................................................................................... 45 Property Element Syntax .......................................................................................................................................................... 48 Content Properties...................................................................................................................................................................... 51 The TextBlock Content Property............................................................................................................................................. 55 Sharing Brushes (and Other Resources) ............................................................................................................................... 57 Resources Are Shared ................................................................................................................................................................ 61 A Bit of Vector Graphics ............................................................................................................................................................ 62 Stretching with Viewbox ........................................................................................................................................................... 71 Styles ............................................................................................................................................................................................... 74 A Taste of Data Binding ............................................................................................................................................................ 80 3 Chapter 3: Basic Event Handling .................................................................... 83 The Tapped Event ........................................................................................................................................................................ 83 Routed Event Handling ............................................................................................................................................................. 86 Overriding the Handled Setting ............................................................................................................................................. 92 Input, Alignment, and Backgrounds ..................................................................................................................................... 93 Size and Orientation Changes ................................................................................................................................................ 97 Bindings to Run? .......................................................................................................................................................................101 Timers and Animation .............................................................................................................................................................103 Chapter 4: The Border Element ..................................................................... 111 The Border Element ..................................................................................................................................................................111 Rectangle and Ellipse ...............................................................................................................................................................115 The StackPanel ...........................................................................................................................................................................117 Horizontal
Recommended publications
  • Understanding the Attack Surface and Attack Resilience of Project Spartan’S (Edge) New Edgehtml Rendering Engine
    Understanding the Attack Surface and Attack Resilience of Project Spartan’s (Edge) New EdgeHTML Rendering Engine Mark Vincent Yason IBM X-Force Advanced Research yasonm[at]ph[dot]ibm[dot]com @MarkYason [v2] © 2015 IBM Corporation Agenda . Overview . Attack Surface . Exploit Mitigations . Conclusion © 2015 IBM Corporation 2 Notes . Detailed whitepaper is available . All information is based on Microsoft Edge running on 64-bit Windows 10 build 10240 (edgehtml.dll version 11.0.10240.16384) © 2015 IBM Corporation 3 Overview © 2015 IBM Corporation Overview > EdgeHTML Rendering Engine © 2015 IBM Corporation 5 Overview > EdgeHTML Attack Surface Map & Exploit Mitigations © 2015 IBM Corporation 6 Overview > Initial Recon: MSHTML and EdgeHTML . EdgeHTML is forked from Trident (MSHTML) . Problem: Quickly identify major code changes (features/functionalities) from MSHTML to EdgeHTML . One option: Diff class names and namespaces © 2015 IBM Corporation 7 Overview > Initial Recon: Diffing MSHTML and EdgeHTML (Method) © 2015 IBM Corporation 8 Overview > Initial Recon: Diffing MSHTML and EdgeHTML (Examples) . Suggests change in image support: . Suggests new DOM object types: © 2015 IBM Corporation 9 Overview > Initial Recon: Diffing MSHTML and EdgeHTML (Examples) . Suggests ported code from another rendering engine (Blink) for Web Audio support: © 2015 IBM Corporation 10 Overview > Initial Recon: Diffing MSHTML and EdgeHTML (Notes) . Further analysis needed –Renamed class/namespace results into a new namespace plus a deleted namespace . Requires availability
    [Show full text]
  • Microsoft Patches Were Evaluated up to and Including CVE-2020-1587
    Honeywell Commercial Security 2700 Blankenbaker Pkwy, Suite 150 Louisville, KY 40299 Phone: 1-502-297-5700 Phone: 1-800-323-4576 Fax: 1-502-666-7021 https://www.security.honeywell.com The purpose of this document is to identify the patches that have been delivered by Microsoft® which have been tested against Pro-Watch. All the below listed patches have been tested against the current shipping version of Pro-Watch with no adverse effects being observed. Microsoft Patches were evaluated up to and including CVE-2020-1587. Patches not listed below are not applicable to a Pro-Watch system. 2020 – Microsoft® Patches Tested with Pro-Watch CVE-2020-1587 Windows Ancillary Function Driver for WinSock Elevation of Privilege Vulnerability CVE-2020-1584 Windows dnsrslvr.dll Elevation of Privilege Vulnerability CVE-2020-1579 Windows Function Discovery SSDP Provider Elevation of Privilege Vulnerability CVE-2020-1578 Windows Kernel Information Disclosure Vulnerability CVE-2020-1577 DirectWrite Information Disclosure Vulnerability CVE-2020-1570 Scripting Engine Memory Corruption Vulnerability CVE-2020-1569 Microsoft Edge Memory Corruption Vulnerability CVE-2020-1568 Microsoft Edge PDF Remote Code Execution Vulnerability CVE-2020-1567 MSHTML Engine Remote Code Execution Vulnerability CVE-2020-1566 Windows Kernel Elevation of Privilege Vulnerability CVE-2020-1565 Windows Elevation of Privilege Vulnerability CVE-2020-1564 Jet Database Engine Remote Code Execution Vulnerability CVE-2020-1562 Microsoft Graphics Components Remote Code Execution Vulnerability
    [Show full text]
  • (RUNTIME) a Salud Total
    Windows 7 Developer Guide Published October 2008 For more information, press only: Rapid Response Team Waggener Edstrom Worldwide (503) 443-7070 [email protected] Downloaded from www.WillyDev.NET The information contained in this document represents the current view of Microsoft Corp. on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This guide is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY. 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, by any means (electronic, mechanical, photocopying, recording or otherwise), or for any purpose, without the express written permission of Microsoft. 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. 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.
    [Show full text]
  • Windows Tweaks Guide
    Windows Tweaks Guide For By Windows Geeks Team Introduction .......................................................................................................................................... 5 Important Notes on This Guide........................................................................................................... 5 Usage Instruction.................................................................................................................................. 5 No Warranty .......................................................................................................................................... 5 Hosting, Distribution & Translation ................................................................................................... 6 Tweaks for Windows XP ...................................................................................................................... 6 Before You Begin Tweaking XP ................................................................................................. 6 Tweaks for Startup ..................................................................................................................... 8 Tweaks for Shutdown .............................................................................................................. 10 Tweaks for Mouse .................................................................................................................... 10 Tweaks for Start Menu ............................................................................................................
    [Show full text]
  • Directx 11 Extended to the Implementation of Compute Shader
    DirectX 1 DirectX About the Tutorial Microsoft DirectX is considered as a collection of application programming interfaces (APIs) for managing tasks related to multimedia, especially with respect to game programming and video which are designed on Microsoft platforms. Direct3D which is a renowned product of DirectX is also used by other software applications for visualization and graphics tasks such as CAD/CAM engineering. Audience This tutorial has been prepared for developers and programmers in multimedia industry who are interested to pursue their career in DirectX. Prerequisites Before proceeding with this tutorial, it is expected that reader should have knowledge of multimedia, graphics and game programming basics. This includes mathematical foundations as well. Copyright & Disclaimer Copyright 2019 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected]
    [Show full text]
  • Windows 7 Training for Developers
    Windows 7 Training for Developers Course 50218 - 4 Days - Instructor-led, Hands-on Introduction This instructor-led course provides students with the knowledge and skills to develop real-world applications on the Windows 7 operating system, using managed and native code. Windows 7 is the latest client operating system release from Microsoft. Windows 7 offers improvements in performance and reliability, advanced scenarios for user interaction including multi-touch support at the operating system level, innovative hardware changes including sensor support and many other features. The course is packed with demos, code samples, labs and lab solutions to provide an deep dive into the majority of new features in Windows 7, and the primary alternatives for interacting with them from managed code. This course is intended for developers with Win32 programming experience in C++ or an equivalent experience developing Windows applications in a .NET language. At Course Completion After completing this course, students will be able to: Design and implement applications taking advantage of the Windows 7 taskbar, shell libraries and other UI improvements Integrate location-based and general sensors into real-world applications Augment applications with multi-touch support Integrate high-end graphics support into native Windows applications Design backwards-compatible applications for Windows 7 and earlier versions of the Windows operating system Improve application and system reliability and performance by using Windows 7 background services, instrumentation, performance and troubleshooting utilities Prerequisites Before attending this course, students must have: At least cursory familiarity with Win32 fundamentals. Experience in Windows C++ programming. or- Experience in Windows applications development in a .NET language Course Materials The student kit includes a comprehensive workbook and other necessary materials for this class.
    [Show full text]
  • Microsoft Patches Were Evaluated up to and Including CVE-2019-1488
    Honeywell Security Group 2700 Blankenbaker Pkwy, Suite 150 Louisville, KY 40299 Phone: 1-502-297-5700 Phone: 1-800-323-4576 Fax: 1-502-666-7021 https://www.security.honeywell.com The purpose of this document is to identify the patches that have been delivered by Microsoft® which have been tested against Pro-Watch. All the below listed patches have been tested against the current shipping version of Pro-Watch with no adverse effects being observed. Microsoft Patches were evaluated up to and including CVE-2019-1488. Patches not listed below are not applicable to a Pro-Watch system. 2019 – Microsoft® Patches Tested with Pro-Watch .NET Quality Rollup for .NET Framework CVE-2019-1488 Microsoft Defender Security Feature Bypass Vulnerability CVE-2019-1485 VBScript Remote Code Execution Vulnerability CVE-2019-1484 Windows OLE Remote Code Execution Vulnerability CVE-2019-1483 Windows Elevation of Privilege Vulnerability CVE-2019-1476 Windows Elevation of Privilege Vulnerability CVE-2019-1474 Windows Kernel Information Disclosure Vulnerability CVE-2019-1472 Windows Kernel Information Disclosure Vulnerability CVE-2019-1471 Windows Hyper-V Remote Code Execution Vulnerability CVE-2019-1470 Windows Hyper-V Information Disclosure Vulnerability CVE-2019-1469 Win32k Information Disclosure Vulnerability CVE-2019-1468 Win32k Graphics Remote Code Execution Vulnerability CVE-2019-1467 Windows GDI Information Disclosure Vulnerability CVE-2019-1466 Windows GDI Information Disclosure Vulnerability CVE-2019-1465 Windows GDI Information Disclosure Vulnerability
    [Show full text]
  • TERKA: Enabling Tamil Script Rendering in .NET Micro Framework
    TERKA: Enabling Tamil script rendering in .NET Micro Framework Jan Kučera1,2, Vladimír Mach1, Dominik Škoda1, Matěj Zábský1 1 Faculty of Mathematics and Physics 2 Department of South and Central Asia Charles University, Czech Republic Charles University, Czech Republic [email protected], [email protected], [email protected], [email protected] Abstract In this paper, we present our contribution to the .NET Micro Framework that enables complex script rendering on small, embedded devices, and we provide a reference implementation for rendering the Tamil script. We also discuss the design of Tamil bitmap fonts and suggest the smallest proportional font possible. Keywords: embedded devices, text rendering, bitmap fonts, Tamil engine Introduction and Overview Microsoft .NET Micro Framework is an open source platform for developing small, resource constrained devices, that emerged in Microsoft Research over 10 years ago. It allows developers to leverage their existing knowledge of managed development and powerful toolset to develop and debug embedded products rapidly. On one side, hardware platforms like .NET Gadgeteer that build on top of the .NET Micro Framework are used for rapid prototyping in commercial research [1] or at secondary schools and universities for teaching students the basic principles of software development, hardware engineering and industrial design [2]. On the other side, .NET Micro Framework is becoming one of the technology backing up the Internet of Things development [3]. The framework comes with simple text rendering engine that uses highly optimized bitmap font format with no support for complex scripts, glyph shaping, text directionality or extended Unicode planes, effectively limiting the number of scripts and languages the .NET Micro Framework can render.
    [Show full text]
  • Windows 7 –KB Artikelliste 2009-2015
    Windows 7 – KB Artikelliste 2009-2015 Mai 2015 3020370 Update the copy of the Cmitrust.dll file in Windows Q3020370 KB3020370 Mai 6, 2015 3022345 Update to enable the Diagnostics Tracking Service in Windows Q3022345 KB3022345 Mai 5, 2015 3062591 Microsoft security advisory: Local Administrator Password Solution (LAPS) now available: Mai 1, 2015 Q3062591 KB3062591 Mai 1, 2015 April 2015 3045999 MS15-038: Description of the security update for Windows: April 14, 2015 Q3045999 KB3045999 April 30, 2015 3042826 POSIX subsystem crashes when you try to create a Telnet session in Windows Q3042826 KB3042826 April 30, 2015 3013531 Update to support copying .mkv files to Windows Phone from a computer that is running Windows Q3013531 KB3013531 April 30, 2015 890830 The Microsoft Windows Malicious Software Removal Tool helps remove specific, prevalent malicious software from computers that are running supported versions of Windows Q890830 KB890830 April 30, 2015 3046480 Update helps to determine whether to migrate the .NET Framework 1.1 when you upgrade Windows 8.1 or Windows 7 Q3046480 KB3046480 April 29, 2015 3045645 Update to force a UAC prompt when a customized .sdb file is created in Windows Q3045645 KB3045645 April 29, 2015 3033092 The Microsoft .NET Framework 4.6 RC (Web Installer) for Windows Vista SP2, Windows 7 SP1, Windows 8, Windows 8.1, Windows Server 2008 SP2, Windows Server 2008 R2 SP1, Windows Server 2012 and Windows Server 2012 R2 Q3033092 KB3033092 April 29, 2015 3033091 The Microsoft .NET Framework 4.6 RC (Offline Installer)
    [Show full text]
  • 1. Technical Problems
    УДК 004.925.4 DIRECTX 11 Vionkov A.A. Scientific supervisor – Associate professor Kuznetsova N.O. Siberian Federal University Application Programming Interface is a set of ready-made classes, procedures, functions, structures and constants provided by the application (libraries, services) for use in external software. It is used by programmers to write various applications. DirectX is a set of API which was created for programming on Microsoft Windows operating system. Mostly it is used to write computer games. DirectX Software Development Kit is available for free downloading from Microsoft homepage. The updated versions of DirectX are usually included with the gaming application because of constant updates and additions. Almost all of the DirectX API parts are a set of COM-compatible objects. Component Object Model is a technological standard from Microsoft designed to create software, based on the interactive components, where each of them can be used simultaneously in many programs. General components of DirectX are: • DirectDraw for video renderer in media applications; • DirectWrite for Fonts; • Direct2D for 2D Graphics; • Direct3D (D3D) for drawing 3D graphics; • DXGI for support Direct3D 10 and up; • DirectCompute for GPU Computing; • DirectSound3D (DS3D) for the playback of 3D sounds; • DirectX Media, consisting of DirectAnimation for 2D/3D web animation, DirectShow for multimedia playback, DirectX Transform for web interactivity and Direct3D Retained Mode for higher level 3D graphics; DirectShow contains DirectX plug-ins for audio signal processing and DirectX Video Acceleration for accelerated video playback. • DirectX Diagnostics (DxDiag) to diagnose and generate reports on components related to DirectX, such as audio, video, and input drivers.
    [Show full text]
  • Study of Mesh Generation and Optimization Techniques Applied to Parametric Forms
    University of Liège - Faculty of Applied Sciences Master thesis ATFE0002-1 Study of mesh generation and optimization techniques applied to parametric forms Graduation Studies conducted for obtaining the Master’s degree in Computer science by Julien Vandenbergh Academic promoter: Éric Béchet Industrial promoters: Sébastien Magdelyns & Terry Moës Academic year of 2019-2020 Abstract This master thesis is focused on the creation of 3D meshes from parametric forms, in particular texts and fonts. The algorithm developed in this work is focused towards being in- tegrated into a real-time rendering engine. This master thesis is done with the collaboration of the University of Liège and Deltatec. The first step is to find a way to extract the parametric form of the text to be drawn. This extraction is based on a previous R&D done at Deltatec. It is using Direct Write and Direct 2D, both are libraries provided by DirectX. Once the parametric forms that describe the text is extracted, a discretisation step is done to create concrete points in 2D space. Those points are then used to create a mesh by triangulating them either using Monotone Polygons Triangulation1 or by Constrained Delaunay Triangulation. Once a 2D mesh is generated, depth is added through extrusion. The normal computation process is done during the extrusion but it has some pitfalls. The normal computation request a special attention to avoid lighting inconsistencies and errors. The algorithm as a whole is timed and compared with the current in-use solution in Deltatec’s proprietary engine. The results show that the developed algorithm, despite not being optimised, is close to the current one in terms of efficiency.
    [Show full text]
  • Documentation of the Plplot Plotting Software I
    Documentation of the PLplot plotting software i Documentation of the PLplot plotting software Documentation of the PLplot plotting software ii Copyright © 1994 Maurice J. LeBrun, Geoffrey Furnish Copyright © 2000-2005 Rafael Laboissière Copyright © 2000-2016 Alan W. Irwin Copyright © 2001-2003 Joao Cardoso Copyright © 2004 Andrew Roach Copyright © 2004-2013 Andrew Ross Copyright © 2004-2016 Arjen Markus Copyright © 2005 Thomas J. Duck Copyright © 2005-2010 Hazen Babcock Copyright © 2008 Werner Smekal Copyright © 2008-2016 Jerry Bauck Copyright © 2009-2014 Hezekiah M. Carty Copyright © 2014-2015 Phil Rosenberg Copyright © 2015 Jim Dishaw Redistribution and use in source (XML DocBook) and “compiled” forms (HTML, PDF, PostScript, DVI, TeXinfo and so forth) with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code (XML DocBook) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified. 2. Redistributions in compiled form (transformed to other DTDs, converted to HTML, PDF, PostScript, and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Important: THIS DOCUMENTATION IS PROVIDED BY THE PLPLOT PROJECT “AS IS” AND ANY EXPRESS OR IM- PLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PLPLOT PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    [Show full text]