快捷索引


会员福利

资源无源时,可利用百度网盘 & 迅雷云盘取回

此内容仅供注册用户。请 %登录%.

[Professional.WPF.Programming.Net.Development.with.the.Windows.Presentation …
6.37MB

中文名: Professional WPF Programming: .Net Development with the Windows Presentation Foundation

原名: Professional WPF Programming: .Net Development with the Windows Presentation Foundation

作者: Chris Andrade,

Shawn Livermore,

Mike Meyers,

ScottVan Vliet

图书分类: 软件

资源格式: PDF

版本: 文字版

出版社: Wiley Publishing, Inc.

书号: 978-0-470-04180-2

发行时间: 2007年

地区: 美国

语言: 英文

简介:

《Professional WPF Programming: .Net Development with the Windows Presentation Foundation》(Professional WPF Programming: .Net Development with the Windows Presentation Foundation)文字版[PDF] 

目录:

Acknowledgments ix

Introduction xix

Chapter 1: Overview of Windows Presentation Foundation 1

A Brief History of the Windows API 2

Platform Evolution 2

Introducing .NET Framework 3.0 3

Meet Windows Presentation Foundation 3

Guiding Design Principles 3

Architecture 5

XAML 15

Declarative vs. Imperative 15

Visual Design Tools 18

XamlPad 18

Microsoft Expression Blend 19

Visual Designer for Windows Presentation Foundation 20

Electric Rain ZAM 3D 21

Mobiform Aurora 22

Summary 23

Chapter 2: WPF and .NET Programming 25

Getting Started 26

Required Installations 26

Types of WPF Applications 26

My First WPF Application 27

WPF Development Concepts 29

XAML 29

The Application Object 30

Creating the User Interface 32

Handling Events 35

Working with Controls 41

Triggers 51

Language Support 58

Deployment 61

Summary 61

xii

Contents

Chapter 3: Anatomy of a WPF-Enabled Application 63

Project Composition 63

App.Manifest 66

AssemblyInfo.cs 66

Resources.resx 68

Settings.settings 68

MyApp.xaml 70

.NET Framework 3.0 Windows Application 71

Window1.xaml 72

XAML Browser Application 73

Page1.xaml 73

WCF Service Library 75

Class1.cs 75

WPF Custom Control Library 78

UserControl1.xaml 79

Summary 82

Chapter 4: Building a Rich UI with Microsoft Expression Blend — Part I 83

Overview 84

The Design Environment 85

Workspace Panels 86

The Artboard 87

Configuring the Environment 88

Project Structure 90

Adding a New Project File 90

Building and Deploying a Project 91

Creating Vector Objects 91

Shapes 92

Paths 93

Manipulating Objects with the Properties Panel 94

The Transform Panel 94

The Brushes Panel 95

Opacity, Transparency, and Visibility 97

Manipulating Text 98

Managing Layouts 99

UI Layout Panels 100

Other Layout Controls 103

Nesting Layout Panels 103

xiii

Contents

Animation 104

Timeline Sub-Panel 104

Keyframes 105

Animate an Object’s Property 106

Motion Paths 106

Triggers 107

Creating Controls 108

Templates 110

Styles 111

States 112

Importing Audio/Video Media 113

Summary 113

Chapter 5: Building a Rich UI with Microsoft Expression Blend — Part II 115

Expression Blend Workflow 116

Code Editing with Visual Studio 2005 117

Handling User Input 118

Keyboard and Mouse Classes 118

Events and Event Handling 118

Positioning 120

Hit Testing 124

The WPF Animation API 135

Animation Classes 135

Creating a Dynamic Animation Procedurally with Code 135

Programmatic Animation 139

Interacting with Storyboards 143

WPF Drawing API 145

Geometry 145

Shapes 146

Brushes 149

Summary 153

Chapter 6: Special Effects 155

Brushes 156

SolidColorBrush 156

GradientBrush 162

ImageBrush 165

DrawingBrush 167

VisualBrush 169

xiv

Contents

Bitmap Effects 171

Transformations 175

TranslateTransform 178

ScaleTransform 180

SkewTransform 183

RotateTransform 186

Opacity Masks 188

Putting It All Together — Combining Effects 191

Bouncing Ball with Reflection Example 191

Animated Image Viewer Example 197

Summary 203

Chapter 7: Custom Controls 205

Overview 206

Control Base Classes 207

The UserControl Class 207

Creating a User Control 207

Data Binding in WPF 217

Binding Markup Extensions 217

Binding Modes 217

Data Templates 219

Data Conversions 221

Creating and Editing Styles 222

Specifying a Style’s Target Type 223

Inheriting and Overriding Styles 224

Style Triggers 226

Customizing Existing Controls with Templates 228

Summary 231

Chapter 8: Using WPF in the Enterprise 233

WPF Application Models 234

Standalone Applications 235

Browser-Based Applications 238

Security Considerations 247

State Management 248

Application Object 248

Isolated Storage 250

State Management Example 252

xv

Contents

Navigation 258

Elements of Navigation 258

Structured Navigation 259

Navigation Topologies 269

Application Localization 286

Automatic Layout Guidelines 287

Using Grids for Flexibility 289

Localization Attributes and Comments 290

WPF Deployment Models 291

Building Applications 292

Deploying Standalone Windows Applications 294

Deploying XAML Browser Applications 295

Deploying the .NET Framework 3.0 Runtime 296

Summary 298

Chapter 9: Security 299

WPF Security Model 299

Trusted Versus Express Applications 300

Core OS Security 300

LUA 301

Virtualization 301

Sandboxing 301

Cryptography Next Generation 302

CLR Security 302

Code Access Security 303

The Critical Code Methodology 311

Verification 313

Microsoft Internet Explorer Security 313

Zone Restrictions 313

XBAP Sandbox Workarounds 314

XAML Browser Application Security 315

ClickOnce Security 323

Trusted Publishers 323

Personal Certificate File 324

.NET 3.0 Security Utilities 327

Summary 328

xvi

Contents

Chapter 10: WPF and Win32 Interop 329

Win32 User Interface Overview 330

How WPF and HWNDs Interoperate 330

Using Win32 HWNDs Inside of WPF 331

Hosting a Win32 Button in WPF 332

Using WPF in Win32 Applications 335

Adding Windows Forms Controls to WPF 337

Adding Your WindowsFormsHost in Code 337

Adding Your HwndHost in XAML 339

Adding ActiveX Controls to WPF 339

Adding the ActiveX Control in XAML 344

Adding WPF Controls to Windows Forms 345

Affecting Control Properties 349

Summary 351

Chapter 11: Advanced Development Concepts 353

WPF Architecture 354

Core Subsystems 356

WPF Threading Model 359

Desktop Window Manager 360

The WPF Framework 361

Dispatcher Object 362

DependencyObject/DependencyProperty 362

Application 363

Freezable 364

Visual 364

UIElement 370

FrameworkElement 371

Control 371

A Deeper Look at XAML 373

XAML Under the Hood 373

Manipulating XAML On-the-Fly 378

Deconstructing Window1.xaml 382

x:Class 383

XAML Markup Extensions 385

XAML and Custom Types 386

xvii

Contents

WPF Multithreading 388

Single-Threaded Application Model 388

Thread Affinity and DispatcherObject 389

WPF Dispatcher 390

Working with Single-Threaded Applications 391

Asynchronous Threading 393

Windows Communication Foundation 397

Service Orientation 397

WCF Architecture 398

WCF Fundamentals 399

Building a WCF Service 402

Windows Workflow Foundation 409

Workflow Defined 410

WF Architecture 411

WF Fundamentals 411

Summary 427

Index 429

内容介绍:

This is an exciting time for developers using Microsoft technologies. A seemingly endless array of new

platforms, techniques, and tools is now available or will soon be released. The developer’s playground is

growing fast. One of the new platforms emerging from the think-tank at Microsoft is the .NET

Framework 3.0, a key component of which (and the subject of this book) is the Windows Presentation

Foundation (WPF). WPF provides both developers and designers with a unified platform for creating

rich-media applications that take full advantage of the graphics capabilities of modern PC hardware.

We’ve come a long way from the command-line interfaces of decades past. Today’s application user

expects a visually engaging and streamlined interactive experience due in part to their exposure to rich

media and content found on the Internet. WPF is all about creating a rich user interface that meets these

expectations, incorporating media of all types, such as animation, video, and audio. Furthermore,

through the use of a new markup syntax called XAML and a new suite of design tools called Microsoft

Expression Blend, developers and designers can now collaborate on projects seamlessly as never before.

Prior to WPF, designers would create graphical elements for applications and hand those elements off to

developers in the form of image files. Developers would then have to model a user interface (UI) around

them. Designers can now model UI using Expression Blend, save the design as a XAML file, and simply

hand the file off to a developer to code against in Visual Studio using WPF.

This book covers the concepts and components that make up the Windows Presentation Foundation.

You learn how to create a rich UI, exploring the various controls now available to you, and how to lever-age the new content model that WPF provides. You explore the WPF object model as well as the new

subsystems offered in WPF, such as the dependency property system and the routed event model. You

learn how to develop and deploy WPF applications targeting both the desktop and the browser. This

book also covers the new XAML syntax, which is a markup language used to define UI in your WPF

applications, regardless of whether you are developing for a standalone Windows-based environment or

targeting the web. Additionally, you learn the basics of working with Expression Blend, the new graphi-cal design tool offered by Microsoft.

WPF is a large platform, and we’ve tried to cover a wide range of topics in this book. Our intent is to

touch on a bit of everything WPF has to offer, so you know not only what’s provided by the platform,

but also how to utilize it. Of course, because it’s a large platform, we won’t be able to cover everything,

but we’ve tried to pick the essential concepts you’ll need to get started. We hope you find it both fun and

educational and that it provides a solid foundation for you as you venture in to the new world of rich UI

development using Windows Presentation Foundation.

Whom This Book Is For

This book is aimed primarily at .NET Framework developers who want to learn how to develop applica-tions using Microsoft’s new presentation framework, WPF. Designers who may consider using the new

Expression Blend suite of design tools and who are seeking to understand how these tools will enhance

collaboration with developers will also find this book to be a good introduction. For new developers,

xx

Introduction

there is some value in learning the new XAML syntax, but most concepts will be too advanced. For these

readers, we suggest learning .NET 2.0 as a positive first step toward WPF.

Readers who will find this book useful include:

❑ Microsoft .NET application developers looking to learn about the new WPF platform

❑ Designers looking to gain insight into Microsoft Expression Blend and the collaboration capabil-ities offered by WPF and the tools that support it

In addition, familiarity with the following related technologies is a strong indicator that this book is for

you:

❑ Microsoft .NET Framework

❑ C#

❑ Web Services

❑ HTML

❑ CSS

Of the preceding list, a basic understanding of the .NET Framework and C# is essential. Familiarity with

Web Services, HTML markup, and CSS concepts would be beneficial, but is not required to understand

the content of this book. Those readers without at least .NET Framework and C# knowledge should

instead refer to books such as Professional .NET Framework 2.0 (ISBN 978-0-7645-7135-0) and Professional

C# 2005 (ISBN 978-0-7645-7534-1).

Reading this book from cover to cover, in sequence, is not a requirement. We suggest reading Chapters 1

through 3 initially, to get a basic understanding of WPF and XAML. After that, skipping around through

the chapters, as interest or needs dictate, should be fine.

What This Book Covers

Professional WPF Programming provides a developer-level tutorial of WPF programming techniques, pat-terns, and use cases.

The book begins with an overview of WPF. Questions such as “What is WPF?”, “How do I start using

WPF?” and “What does WPF have to offer me?” are answered early in the first chapter, followed swiftly

by a detailed look at the subsystems and graphical features offered by the platform.

Following the overview, you dive right into the programming techniques you need for WPF. Using

Visual Studio to create some examples, you get up-to-speed fast and start creating applications right

away. Also, you are introduced to XAML, the new markup syntax for creating a UI. XAML is actually a

separate technology from WPF, but WPF uses it extensively.

With the basic concepts and programming techniques of WPF under your belt, you take a brief journey

into the world of design tools. Microsoft now offers its own suite of compelling design tools, and you’ll

get some firsthand experience with the new Microsoft Expression Blend. Using Expression Blend, you

xxi

Introduction

create advanced UI and learn to implement styling, layout, and animation. You also see how easy it is to

save your design in XAML and then use that very same markup in Visual Studio to begin coding appli-cation logic.

Next, you learn how to create special effects in WPF, including bitmap effects, transformations, and the

use of brush objects to get glass or reflection effects. The book demonstrates these techniques and pro-vides a foundation for creating visually stunning elements in your applications.

Following special effects, you are introduced to custom control authoring in WPF. WPF provides a very

customizable object model that allows you to apply styles and templates to existing elements. A new

content model allows you to place almost any element inside of another element. Given these new capa-bilities, you’re unlikely to encounter many scenarios where you need to create a custom control.

However, we “never say never,” and there may be some scenarios in which a custom control is the way

to go. This book covers the topics you should take into consideration when deciding whether to create a

custom control, as well as how to build a custom control when necessary.

Next, the book dives into developing WPF applications for the enterprise. WPF offers two flavors of

application that you can create: standalone Windows-based, or web-based. The key thing to understand

is that both models utilize the same code-base, XAML, and .NET. This means that specifying your target

hosting environment is really just a matter of tweaking project file settings and then managing deploy-ment. This is extremely powerful stuff, and it is all covered within the enterprise topics discussed in this

book.

After you gain a good understanding of application models and deployment, you will want to under-stand security. Security in WPF is based on the .NET 2.0 CAS security model. Security is also based on

the application model you choose and where the application will be hosted. If it is hosted in a browser,

you will need to understand the Internet Zone permission set. These topics are covered in depth.

With the basics of WPF application development, deployment, and security fully explored, the book

then dives into some more advanced concepts. One of those concepts is how to mix Win32 and WPF

code. Interoperation considerations will be covered. Hosting Win32 in WPF and the reverse is possible,

and you’ll learn how to implement this feature so that you can start incorporating WPF into your Win32

applications right away.

The book finishes with a WPF deep dive into architecture, WPF framework, XAML, and threading con-siderations. In addition, the book covers the basics of both Windows Workflow Foundation (WF) and

Windows Communication Foundation (WCF) so that you can become familiar with the other compo-nents of the .NET Framework 3.0. To round out your understanding of these important components, you

will build a sample WCF service and a simple WF workflow application.

How This Book Is Structured

Professional WPF Programming begins by providing some background on how and why Microsoft is shift-ing away from the long-standing Win32 platform in the direction of WPF. This is followed by an

overview of WPF and the core components and subsystems of the platform. Next, a tour of Expression

Blend is offered, and we provide examples to show you how to build rich UI. The remaining chapters

then focus on individual topics related to WPF development. The book ends with a brief introduction to

two other components that, along with WPF, make the .NET Framework 3.0 such an important and

powerful platform.

xxii

Introduction

The chapter-level breakdown is as follows:

❑ Chapter 1, “Overview of Windows Presentation Foundation”—This chapter explores the evo-lution of the Windows API over the years and how this paved the way for a new platform, WPF.

You will then take a high-level tour of the WPF architecture, including the new graphics capa-bilities and subsystems that are introduced by the platform. Additional development tools are

also introduced.

❑ Chapter 2, “WPF and .NET Programming”—This chapter walks you through the requirements

for building and running WPF applications. You also learn about the various subsystems, such

as the dependency property and routed event systems. Furthermore, you are introduced to the

controls offered by WPF, and you learn how you can modify and extend these controls using the

new constructs provided by the platform.

❑ Chapter 3, Anatomy of a WPF-Enabled Application—This chapter introduces the various

application models you can use in WPF, such as those for standalone and browser-based appli-cations. The anatomy, which includes the files and configuration settings, will also be explored

so that you are able to get up and running quickly developing WPF applications.

❑ Chapter 4, “Building a Rich UI with Microsoft Expression Blend: Part I”—This chapter intro-duces the new tools for designers working with WPF, specifically, Microsoft Expression Blend.

You take a tour of the design environment provided by Expression Blend and look at the project

file structure. The chapter also covers creating vector graphics, layouts, animation, and controls.

❑ Chapter 5, “Building a Rich UI with Microsoft Expression Blend: Part II”—This chapter

builds on the concepts introduced in Chapter 4. You learn about how to add interactivity to

your projects to handle user input, events, and hit testing. The chapter also provides a series of

animation examples and you are introduced to the WPF drawing API. This chapter also illus-trates the collaboration features provided between Expression Blend and Visual Studio 2005.

❑ Chapter 6, “Special Effects”—This chapter explores the rich capabilities and special effects

offered in WPF. Brushes, bitmap effects, and transformations are all covered extensively. Using

these concepts, you can create rich UI both easily and quickly in WPF.

❑ Chapter 7, “Custom Controls”—This chapter tackles custom control development in WPF.

Because of the extensive support for templates and styles in WPF, you will likely find that your

need for custom controls will be slim. However, there are times you will need or want to create

a custom control. This chapter covers not just how to create custom controls, but also how to

determine if you can get by with using the built-in support for templates and styles because

they are such powerful tools.

❑ Chapter 8, “Using WPF in the Enterprise”—This chapter explores the many factors to consider

when building an enterprise-level application with WPF. Application models, deployment,

hosting environment, security considerations, navigation, state management, and localization

are covered thoroughly in this chapter.

❑ Chapter 9, “Security”—This chapter explores the security features of WPF. Security in WPF is pri-marily based on the application model you choose and where your application is hosted. This

chapter covers OS security, CAS security, the Internet security sandbox, and ClickOnce security.

❑ Chapter 10, “WPF and Win32 Interop”—This chapter focuses on how your WPF application

can interoperate with existing Win32 applications. The question “Can I host my WPF applica-tion in a Win32 application?” and vice versa will be answered. You will learn about how

HWNDS differ in WPF from Win32-based applications.

xxiii

Introduction

❑ Chapter 11, “Advanced Development Concepts”—This chapter dives deeper into many con-cepts introduced throughout the book. You get a thorough look at WPF architecture and what

makes WPF tick. You take a tour through the important classes in the WPF framework, such as

the Application and DependencyObject classes. The chapter covers XAML syntax and struc-ture in great depth. Threading in WPF applications is explored. Finally, this chapter takes a

high-level look at two other components of the .NET 3.0 Framework: Windows Workflow

Foundation and Windows Communication Foundation.

What You Need to Use This Book

To develop WPF applications and create the examples in this book, you must have the following

installed:

❑ Windows SDK

❑ .NET Framework 3.0 Runtime Components

❑ Visual Studio 2005 with Visual Studio codename “Orcas” CTP WinFX Development Tools or the

Orcas release of Visual Studio 2005

Chapter 2 outlines these requirements in more detail as well as where and how to obtain the necessary

components.

作者介绍:

Chris Andrade is a Principal with Novera Consulting, a Microsoft Certified Partner specializing in

enterprise architecture and development with .NET and Microsoft server technology. Chris devotes most

of his time to assisting companies in applying Microsoft technologies to improve their business pro-cesses and operations. Chris has worked within a diverse range of business verticals, including automo-tive, healthcare, and mortgage. Chris also takes active participation within the local developer

community, speaking and presenting along the west coast whenever possible.

Shawn Livermore (MCAD, MCSD, PMP) [shawnlivermore.blogspot.com] has been architecting and

developing Microsoft-based solutions for nearly a decade. Shawn has been consulting as an enterprise

and solutions architect for Fortune 500 clientele within highly visible enterprise implementations. His

range of technical competence stretches across platforms and lines of business, but he specializes in

Microsoft .NET enterprise application architectures and Microsoft server-based product integrations.

Shawn lives in the Southern California area with his beautiful wife Shantell and amazing daughter

Elexzandreia. Shawn also enjoys beating his friend Jason at air hockey, basketball, baseball, football,

arcade games, cards, billiards, ping pong, shuffleboard, trivia, golf, racquetball, dirt bike races, cross-country skiing… and pretty much any other sport in existence. Shawn would like to once again remind

Jason, “Who’s your daddy?”

Mike Meyers is president of Novera Consulting Inc, a software development and consulting firm spe-cializing in custom application development utilizing the .NET platform and Microsoft server technol-ogy. Based in Orange County, California, Mike’s company is focused on providing solutions based on

Microsoft platforms and technology to companies spanning multiple industries. Mike has worked in a

number of industries, including mortgage, healthcare, and various ecommerce ventures as developer,

architect, and project manager. When he’s not writing code, Mike is active mountain biking in southern

California, hiking with his four-legged Labrador Dakota or playing music with friends.

ScottVan Vliet is an accomplished Solutions Architect who has spent the past decade delivering suc-cessful Microsoft-based solutions to his clients. Currently a Senior Manager with Capgemini, a world-wide leader in technology consulting services, Scotthas managed, architected, and developed solutions

for companies across the globe. He is also the Microsoft Delivery Leader for Capgemini’s Telecom,

Media & Entertainment practice, providing technical and engagement leadership on all Microsoft-based

projects. Scottcan be reached via his Web site at http://www.scottvanvliet.com/.


书我要,下载先! http://www.books51.com/ 祝您开卷有益!




文章类别:

本文链接: http://www.books51.com/293001.html

【点击下方链接,复制 & 分享文章网址】

Professional WPF Programming: .Net Development → http://www.books51.com/293001.html

上一篇:

下一篇:

0 ratings, 0 votes0 ratings, 0 votes (0 次顶, 0已投票)
你必须注册后才能投票!
Loading...

添加新评论