ebook img

Mastering Windows Presentation Foundation: Master the art of building modern desktop applications on Windows PDF

561 Pages·2017·5.098 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Mastering Windows Presentation Foundation: Master the art of building modern desktop applications on Windows

Mastering Windows Presentation Foundation (cid:46)(cid:66)(cid:84)(cid:85)(cid:70)(cid:83)(cid:2)(cid:85)(cid:73)(cid:70)(cid:2)(cid:66)(cid:83)(cid:85)(cid:2)(cid:80)(cid:71)(cid:2)(cid:67)(cid:86)(cid:74)(cid:77)(cid:69)(cid:74)(cid:79)(cid:72)(cid:2)(cid:78)(cid:80)(cid:69)(cid:70)(cid:83)(cid:79)(cid:2)(cid:69)(cid:70)(cid:84)(cid:76)(cid:85)(cid:80)(cid:81)(cid:2)(cid:66)(cid:81)(cid:81)(cid:77)(cid:74)(cid:68)(cid:66)(cid:85)(cid:74)(cid:80)(cid:79)(cid:84)(cid:2)(cid:80)(cid:79) (cid:56)(cid:74)(cid:79)(cid:69)(cid:80)(cid:88)(cid:84) Sheridan Yuen BIRMINGHAM - MUMBAI Mastering Windows Presentation Foundation Copyright © 2017 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: February 2017 Production reference: 1130217 (cid:49)(cid:86)(cid:67)(cid:77)(cid:74)(cid:84)(cid:73)(cid:70)(cid:69)(cid:2)(cid:67)(cid:90)(cid:2)(cid:49)(cid:66)(cid:68)(cid:76)(cid:85)(cid:2)(cid:49)(cid:86)(cid:67)(cid:77)(cid:74)(cid:84)(cid:73)(cid:74)(cid:79)(cid:72)(cid:2)(cid:45)(cid:85)(cid:69)(cid:16) (cid:45)(cid:74)(cid:87)(cid:70)(cid:83)(cid:90)(cid:2)(cid:49)(cid:77)(cid:66)(cid:68)(cid:70) (cid:21)(cid:23)(cid:2)(cid:45)(cid:74)(cid:87)(cid:70)(cid:83)(cid:90)(cid:2)(cid:52)(cid:85)(cid:83)(cid:70)(cid:70)(cid:85) (cid:35)(cid:74)(cid:83)(cid:78)(cid:74)(cid:79)(cid:72)(cid:73)(cid:66)(cid:78)(cid:2) (cid:35)(cid:21)(cid:2)(cid:20)(cid:49)(cid:35)(cid:14)(cid:2)(cid:54)(cid:44)(cid:16) ISBN 978-1-78588-300-2 (cid:88)(cid:88)(cid:88)(cid:16)(cid:81)(cid:66)(cid:68)(cid:76)(cid:85)(cid:81)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78) Credits Author Copy Editor Sheridan Yuen Pranjali Chury Reviewer Project Coordinator Alex Golesh Vaidehi Sawant Commissioning Editor Proofreader Edward Gordon Safis Editing Acquisition Editor Indexer Chaitanya Nair Rekha Nair Content Development Editor Graphics Zeeyan Pinheiro Kirk D'Penha Technical Editor Production Coordinator Kunal Chaudhari Shantanu N. Zagade About the Author Sheridan Yuen is a Microsoft .NET MCTS and Oracle Java SCJP certified software developer, living in London, England. His passion for coding made him stand out from the crowd right from the start. From his second year onward at university, he was employed to be a teaching assistant for the first year student coding workshops and has since returned as a guest lecturer. Among other prestigious positions, he was the primary software developer for the Ministry of Sound group for four years, working on their main music business application, responsible for creating their multi award winning albums. This application managed to increase its users’ productivity by up to 80% in some cases. In addition to this, he architected a unique ticket scanning application for their award winning nightclub, making it the first club in the world to introduce scanned ticket entry across all streams for their clients. Coming from a musical background and being a qualified audio engineer, with experience of record production and digital audio, this post was a perfect union. He soon became a popular figure in the C# and WPF sections of the Stack Overflow, “question and answer” website, being awarded enough reputation by the community members to raise him to well within the top half percent of all users. While authoring this book and other projects have kept him away for some time, he is keen to return to continue to help new users to get to grips with WPF. I would like to thank my long suffering girlfriend Jemma, who has regularly had to make do without my company for the best part of a year, for her patience while I was composing and writing this book and the many examples in it. I’d also like to thank Chaitanya from Packt Publishing for convincing me to write this book in the first place and without who, this book would not have been written. Finally, I would like to thank Mary Thomson, Professor Sarah Barman and Professor James Orwell in particular, from Kingston University, London, who inspired me to change the direction of my previous career and planted the seed of curiosity that has taken me so far. I would also like to thank James for encouraging me to move from the Bachelor’s Degree course to the integrated Master’s Degree that I ended up gaining and for all of the benefits that this brought with it. About the Reviewer Alex Golesh is an international expert in XAML-based technologies such as Universal Windows Platform (Windows, Windows Phone, HoloLens, Xbox One), Xamarin.Forms, WPF, and Silverlight. Also, Alex specializes in cloud-based solutions such as Microsoft Azure. Alex developed training solutions for Microsoft Learning on Windows Phone and Windows 8 and delivers workshops for developers and enterprises. Alex leads the architecture and development process in multiple projects for his clients. www.PacktPub.com For support files and downloads related to your book, please visit (cid:88)(cid:88)(cid:88)(cid:16)(cid:49)(cid:66)(cid:68)(cid:76)(cid:85)(cid:49)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78). Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at (cid:88)(cid:88)(cid:88)(cid:16)(cid:49)(cid:66)(cid:68)(cid:76)(cid:85)(cid:49)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78) and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at (cid:84)(cid:70)(cid:83)(cid:87)(cid:74)(cid:68)(cid:70)(cid:33)(cid:81)(cid:66)(cid:68)(cid:76)(cid:85)(cid:81)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78) for more details. At (cid:88)(cid:88)(cid:88)(cid:16)(cid:49)(cid:66)(cid:68)(cid:76)(cid:85)(cid:49)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78), you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. (cid:73)(cid:85)(cid:85)(cid:81)(cid:84)(cid:28)(cid:17)(cid:17)(cid:88)(cid:88)(cid:88)(cid:16)(cid:81)(cid:66)(cid:68)(cid:76)(cid:85)(cid:81)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78)(cid:17)(cid:78)(cid:66)(cid:81)(cid:85) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content On demand and accessible via a web browser Customer Feedback Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at (cid:73)(cid:85)(cid:85)(cid:81)(cid:84)(cid:28)(cid:17)(cid:17)(cid:72)(cid:80)(cid:80)(cid:16)(cid:72)(cid:77)(cid:17)(cid:90)(cid:86)(cid:54)(cid:34)(cid:81)(cid:37). (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) (cid:2) If you'd like to join our team of regular reviewers, you can email us at (cid:68)(cid:86)(cid:84)(cid:85)(cid:80)(cid:78)(cid:70)(cid:83)(cid:83)(cid:70)(cid:87)(cid:74)(cid:70)(cid:88)(cid:84)(cid:33)(cid:81)(cid:66)(cid:68)(cid:76)(cid:85)(cid:81)(cid:86)(cid:67)(cid:16)(cid:68)(cid:80)(cid:78). We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products! Table of Contents Preface 1 Chapter 1: A Smarter Way of Working with WPF 7 What is MVVM and how does it help? 8 Models 9 View Models 9 Views 10 Data binding 10 So how does MVVM help? 11 Is there a downside? 12 Debunking the myth about code behind 12 Learning how to communicate again 14 Introducing the ICommand interface 15 Handling events in Attached Properties 18 Making use of delegates 20 Structuring the application code base 24 Summary 34 Chapter 2: Debugging WPF Applications 35 Utilizing the Output window 35 Putting Presentation Trace Sources to work 38 Discovering inner exceptions 43 Debugging data bound values 47 Outputting values to UI controls 48 Catching changing Dependency Property values 48 Exploiting converters 49 Summary 51 Chapter 3: Writing Custom Application Frameworks 52 What is an application framework? 52 Encapsulating common functionality 53 In base classes 58 Through interfaces 62 With Extension methods 66 In UI controls 71 With converters 75 Constructing a custom application framework 82 Separating the Data Access Layer 99 Providing services 106 Implementing Dependency Injection 109 Connecting Views with View Models 118 Summary 126 Chapter 4: Becoming Proficient with Data Binding 127 Data binding basics 127 Binding path syntax 128 Escaping invalid characters 131 Exploring the Binding class 132 Directing data bound traffic 135 Binding to different sources 136 Binding with priority 140 Binding from within control templates 141 Binding source changes 142 Converting data bound values 143 Binding multiple sources to a single target property 149 Dependency Properties 153 Setting metadata 155 Declaring read-only Dependency Properties 159 Registering Attached Properties 160 Prioritizing value setting sources 162 Data templates 168 Taking complete control 172 Displaying hierarchical data 175 Data binding to enumeration collections 179 Summary 182 Chapter 5: Using the Right Controls for the Job 183 Investigating the built-in controls 183 Inheriting framework abilities 184 Laying it on the line 186 Containing controls 187 Canvas 188 DockPanel 191 Grid 193 StackPanel 199 UniformGrid 201 WrapPanel 204 Providing custom layout behavior 205 [ ii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.