logo资料库

Windows Presentation Foundation Development Cookbook.pdf

第1页 / 共728页
第2页 / 共728页
第3页 / 共728页
第4页 / 共728页
第5页 / 共728页
第6页 / 共728页
第7页 / 共728页
第8页 / 共728页
资料共728页,剩余部分请下载后查看
Title Page
Copyright and Credits
Windows Presentation Foundation Development Cookbook
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
WPF Fundamentals
Introduction
The WPF Architecture
Presentation Framework
Presentation Core
Common Language Runtime
Media Integration Library
OS Core
Types of WPF applications
The XAML overview
XAML syntax terminologies
Object element syntax
Property Attribute syntax
Property Element syntax
Content syntax
Collection syntax
Event Attribute syntax
Installing WPF Workload with Visual Studio 2017
Getting ready
How to do it...
Creating WPF applications
Getting ready
How to do it...
There's more...
Creating and navigating from one window to another
Getting ready
How to do it...
How it works...
There's more...
Creating and navigating from one page to another
Getting ready
How to do it...
How it works...
There's more...
Creating a dialog box
Getting ready
How to do it...
How it works...
There's more...
Using the open file dialog
Using the save file dialog
Using the print dialog
Other common dialogs
Creating ownership between windows
Getting ready
How to do it...
How it works...
There's more...
Creating a single instance application
Getting ready
How to do it...
How it works...
There's more...
Passing arguments to WPF applications
Getting ready
How to do it...
How it works...
There's more...
Handling unhandled exceptions
Getting ready
How to do it...
How it works...
There's more...
Using WPF Standard Controls
Introduction
Using the TextBlock control to add plain text
Getting ready
How to do it...
How it works...
There's more...
Using Label to add other controls in text
Getting ready
How to do it...
How it works...
There's more...
Providing a user option to input text
Getting ready
How to do it...
How it works...
There's more...
Windows Clipboard support
Adding spellcheck support
Adding images to your application UI
Getting ready
How to do it...
How it works...
There's more...
Working with ready-to-use 2D shapes
Getting ready
How to do it...
How it works...
There's more...
Adding tooltips to show additional information
Getting ready
How to do it...
How it works...
There's more...
Adding a standard menu to the WPF application
Getting ready
How to do it...
How it works...
There's more...
Adding an access key to menus
Adding icons to menus
Adding checkable menu items
Adding click-event handlers to menus
Providing extra functionalities using the context menu
Getting ready
How to do it...
How it works...
Adding user options with radio buttons and checkboxes
Getting ready
How to do it...
How it works...
There's more...
Working with the progress bar control
Getting ready
How to do it...
How it works...
Using the Slider control to pick a numeric value
Getting ready
How to do it...
How it works...
There's more...
Using the Calendar control in your application
Getting ready
How to do it...
How it works...
There's more...
The SelectionModes property
The DisplayDate property
The DisplayMode property
The BlackoutDates property
Listing items in a Listbox control
Getting ready
How to do it...
How it works...
There's more...
Implementing multi selection
Customizing the ListBoxItem with multiple controls
Providing options to select from a ComboBox
Getting ready
How to do it...
How it works...
There's more...
Adding a status bar to your window
Getting ready
How to do it...
How it works...
Adding a toolbar panel to perform quick tasks
Getting ready
How to do it...
How it works...
Layouts and Panels
Introduction
Building a UI layout using a Grid
Getting ready
How to do it...
How it works...
There's more...
Creating a resizable Grid
Spanning elements across multiple rows and/or columns
Placing elements in uniform cells
Getting ready
How to do it...
How it works...
There's more...
Setting the row and column count
Defining the first cell of the UniformGrid
Filling elements from right to left
Automatically repositioning controls using WrapPanel
Getting ready
How to do it...
How it works...
There's more...
Placing controls in a Stack
Getting ready
How to do it...
How it works...
There's more...
Positioning controls inside a Canvas
Getting ready
How to do it...
How it works...
There's more...
Wrapping UI elements using a Border
Getting ready
How to do it...
How it works...
Creating a scrollable panel
Getting ready
How to do it...
How it works...
Docking controls using the DockPanel
Getting ready
How to do it...
How it works...
There's more...
Rescaling UI elements using a ViewBox
Getting ready
How to do it...
How it works...
There's more...
Creating a tabbed layout
Getting ready
How to do it...
How it works...
Dynamically adding/removing elements in a panel
Getting ready
How to do it...
How it works...
There's more...
Implementing the drag and drop feature
Getting ready
How to do it...
How it works...
There's more...
Working with Data Bindings
Introduction
Working with CLR properties and UI notifications
Getting ready
How to do it...
How it works...
There's more...
Working with dependency properties
Getting ready
How to do it...
How it works...
There's more...
Working with attached properties
Getting ready
How to do it...
How it works...
Data binding to an object
Getting ready
How to do it...
How it works...
Data binding to a collection
Getting ready
How to do it...
How it works...
There's more...
Element-to-element data binding
Getting ready
How to do it...
How it works...
Sorting data in a DataGrid control
Getting ready
How to do it...
How it works...
Grouping data in a DataGrid control
Getting ready
How to do it...
How it works...
There's more...
Filtering data in a DataGrid control
Getting ready
How to do it...
How it works...
Using static bindings
Getting ready
How to do it...
How it works...
Using value converters
Getting ready
How to do it...
How it works...
There's more...
Using multi-value converters
Getting ready
How to do it...
How it works...
Using Custom Controls and User Controls
Introduction
Creating a custom control
Getting ready
How to do it...
How it works...
There's more...
XMLNS attribute declaration
Default styling
Toolbox integration
Customizing the template of a custom control
Getting ready
How to do it...
How it works...
Exposing properties from the custom control
Getting ready
How to do it...
How it works...
Exposing events from a custom control
Getting ready
How to do it...
How it works...
Extending the functionality of a control using behavior
Getting ready
How to do it...
How it works...
Creating a User Control interface
Getting ready
How to do it...
How it works...
Exposing events from a User Control
Getting ready
How to do it...
How it works...
Customizing the XMLNS namespace
Getting ready
How to do it...
How it works...
Using Styles, Templates, and Triggers
Introduction
Creating the style of a control
Getting ready
How to do it...
How it works...
There's more...
Creating the Style of a control based on another Style
Getting ready
How to do it...
How it works...
Applying Style to a control automatically
Getting ready
How to do it...
How it works...
Editing the template of any control
Getting ready
How to do it...
How it works...
There's more...
Creating a property trigger
Getting ready
How to do it...
How it works...
Creating a multi trigger
Getting ready
How to do it...
How it works...
Creating a data trigger
Getting ready
How to do it...
How it works...
Creating a multi data trigger
Getting ready
How to do it...
How it works...
Creating an event trigger
Getting ready
How to do it...
How it works...
Using Resources and MVVM Patterns
Introduction
Using binary resources inside a WPF application
Getting ready
How to do it...
How it works...
There's more...
Using binary resources from another assembly
Getting ready
How to do it...
How it works...
There's more...
Accessing binary resources in code
Getting ready
How to do it...
How it works...
Using static logical resources in WPF
Getting ready
How to do it...
How it works...
There's more...
Using dynamic logical resources in WPF
Getting ready
How to do it...
How it works...
There's more...
Managing logical resources
Getting ready
How to do it...
How it works...
There's more...
Using user selected colors and fonts
Getting ready
How to do it...
How it works...
There's more...
Building an application using the MVVM pattern
Getting ready
How to do it...
How it works...
Using routed commands in a WPF application
Getting ready
How to do it...
How it works...
Working with Animations
Introduction
Scaling an element while rendering
Getting ready
How to do it...
How it works...
Rotating an element while rendering
Getting ready
How to do it...
How it works...
Skewing an element while rendering
Getting ready
How to do it...
How it works...
Moving an element while rendering
Getting ready
How to do it...
How it works...
Grouping multiple transforms
Getting ready
How to do it...
How it works...
There's more...
Creating property-based animations
Getting ready
How to do it...
How it works...
Creating path-based animations
Getting ready
How to do it...
How it works...
Creating key-frame-based animations
Getting ready
How to do it...
How it works...
There's more...
Adding easing effects to animations
Getting ready
How to do it...
How it works...
There's more...
BounceEase
CircleEase
CubicEase
ElasticEase
ExponentialEase
PowerEase
QuadraticEase
QuarticEase
QuinticEase
SineEase
Using WCF Services
Introduction
Creating a WCF service
Getting ready
How to do it...
How it works...
The DataContract attribute
The DataMember attribute
The ServiceContract attribute
The OperationContract attribute
Self-hosting a WCF service
Getting ready
How to do it...
How it works...
There's more...
Hosting a WCF service in an IIS server
Getting ready
How to do it...
How it works...
Integrating a WCF service in a WPF application
Getting ready
How to do it...
How it works...
There's more...
Debugging and Threading
Introduction
Enabling the UI debugging tool for XAML
Getting ready
How to do it...
Navigating through XAML elements using Live Visual Tree
Getting ready
How to do it...
How it works...
There's more...
Inspecting XAML properties using Live Property Explorer
Getting ready
How to do it...
How it works...
There's more...
Updating the UI from a non-UI thread
Getting ready
How to do it...
How it works...
There's more...
Adding cancelation support to long running threads
Getting ready
How to do it...
How it works...
Using the background worker component
Getting ready
How to do it...
How it works...
There's more...
Using a timer to periodically update the UI
Getting ready
How to do it...
How it works...
Interoperability with Win32 and WinForm
Introduction
Hosting WinForm controls in WPF applications
Getting ready
How to do it...
How it works...
There's more...
Hosting WPF controls in WinForm applications
Getting ready
How to do it...
How it works...
Calling Win32 APIs from WPF applications
Getting ready
How to do it...
How it works...
Embedding ActiveX controls in WPF applications
Getting ready
How to do it...
How it works...
Other Books You May Enjoy
Leave a review - let other readers know what you think
Windows Presentation Foundation Development Cookbook 100 recipes to build rich desktop client applications on Windows Kunal Chowdhury
BIRMINGHAM - MUMBAI
Windows Presentation Foundation Development Cookbook Copyright © 2018 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 or its dealers and distributors, will be held liable for any damages caused or alleged to have been 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. Commissioning Editor: Merint Mathew Acquisition Editor: Nitin Dasan Content Development Editor: Akshada Iyer Technical Editor: Supriya Thabe Copy Editor: Safis Editing Project Coordinator: Prajakta Naik Proofreader: Safis Editing Indexer: Aishwarya Gangawane Graphics: Jisha Chirayil Production Coordinator: Shantanu Zagade First published: February 2018 Production reference: 1210218 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78839-980-7 www.packtpub.com
mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content
PacktPub.com 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 www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, 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.
Contributors
分享到:
收藏