Manuals
/
Microsoft
/
Computer Equipment
/
Computer Accessories
Microsoft
9GD00001
manual
Appendix B, 409
Models:
9GD00001
1
432
449
449
Download
449 pages
12.58 Kb
429
430
431
432
433
434
435
436
<
>
Install
A database diagram
Default Namespace
Symbols
Administrative Tools window
Configuring Debug Mode
Resetting All Settings
Setup Welcome window
IDTCommandTarget Interface
Assembly Information
Page 432
Image 432
Appendix
B
Introduction to XAML
409
Page 431
Page 433
Page 432
Image 432
Page 431
Page 433
Contents
Page
Microsoft Visual Studio
About the Author
About the Technical Editor
Joe Mayo
Terms of USE
To my son, Kamo
This page intentionally left blank
Contents at a Glance
Viii Microsoft Visual Studio 2010 a Beginner’s Guide
Contents
Learning Just Enough C# and VB.NET Types and Members
Contents
Xii
Xiii
Xiv
Part V Appendixes
This page intentionally left blank
Acknowledgments
Xvii
This page intentionally left blank
Introduction
Xix
Xx Microsoft Visual Studio 2010 a Beginner’s Guide
Introduction
This page intentionally left blank
Part
This page intentionally left blank
Chapter
What Is Visual Studio 2010 About?
Key Skills & Concepts
Automatically Generated Code
Rapid Coding Experience
Everything at Your Fingertips
Customizability and Extensibility
Installing Visual Studio
Microsoft Visual Studio 2010 Setup window
Setup Welcome window
Setup Licensing window
Setup Customization window
Setup Progress window
Setup Success window
Checking for service releases
Navigating the Visual Studio 2010 Environment
Menu
10 Visual Studio 2010 Start screen
Toolbar
Work Area
Solution Explorer
Managing VS Windows
Toolbox
Status Bar
Expanding and Collapsing Windows
11 Window title bar icons
Docking Windows
13 Pinned Toolbox
Floating Windows
14 Dragging a window for docking
Tabbed Windows
15 Floating a window
Closing and Opening Windows
16 Tabbed document windows
Modifying Environment Settings after Setup
17 Import and Export Settings Wizard
Exporting Selected Environment Settings
18 Choose Settings To Export window
Importing Selected Environment Settings
19 Name Your Settings File window
20 Export Complete window
21 Save Current Settings window
22 Choose a Collection Of Settings To Import window
Resetting All Settings
23 Choose Settings To Import window
24 Import Complete window
25 Default Collection Of Settings window
Familiarization with Visual Studio Project Types
26 Reset Complete window
Windows Projects
27 Selecting a New Project via the File menu
Web Projects
28 New Project window
Summary
Office Projects
SharePoint Projects
Database Projects
Learning Just Enough C# or VB.NET Basic Syntax
Starting a Bare-Bones Project
Learning Just Enough C# or VB.NET Basic Syntax
A Console application in the Solution Explorer
Examining the Code Skeleton
Listing 2-1 Console application skeleton code
Main Method
Program Class
FirstProgram Namespace
An Overview of the VS Code Editor
VS Code editor
Class and Member Locators
Bookmarks
Bookmark Shortcut Keys
Setting Editor Options
Bookmarks window
Options window
Using snippets
Saving Time with Snippets
Filling in the Snippet template
Coding Expressions and Statements
Making Intellisense Work for You
Microsoft Visual Studio 2010 a Beginner’s Guide
Running Programs
10 Intellisense options
Primitive Types and Expressions
Primitive Types
NET
Primitive Types
Expressions
Enums
Ternary and Immediate If Operators
Listing 2-2 a ternary operator example
Listing 2-4 Using an enum
Listing 2-3 An example of an enum
Branching Statements
If and else Snippets
11 The C# if statement snippet template
Switch/Select Statements
Switch Statement Snippets
13 a switch snippet template
Loops
For Loops
For Loop Snippet
For Each Loops
For Each Loop Snippet
17 The C# for each loop snippet template
While Loops
While Loop Snippet
Do Loops
Do Loop Snippet
22 The VB do loop while snippet template
Learning Just Enough # and VB.NET Types and Members
Creating Classes
Class Syntax
Listing 3-1 a new Employee class
Learning Just Enough C# and VB.NET Types and Members
Listing 3-2 Code that uses a class
Class Inheritance
Listing 3-3 Class inheritance
Listing 3-4 Code using inheritance
Class Snippet
Declaring and Using a Method
Writing Methods
Listing 3-5 Declaring and calling a method
# MessagePrinter.cs
Program.PrintMessageStatic MessagePrinter.PrintMessageShared
Declaring Parameters and Passing Arguments
Listing 3-6 Declaring a method that takes parameters
# MessagePrinter.cs
VB MessagePrinter.vb
Returning Data and Using Method Results
Listing 3-7 Returning values from methods
# Calc.cs
Method Snippets
VB sub snippet template
Declaring and Using Fields
Listing 3-8 Using fields and properties
Coding Fields and Properties
Microsoft Visual Studio 2010 a Beginner’s Guide
Declaring and Using Properties
Microsoft Visual Studio 2010 a Beginner’s Guide
Listing 3-9 Property that wraps object state with no logic
Property Snippet
Listing 3-10 Auto-implemented properties
Summary
This page intentionally left blank
Learning Just Enough # and VB.NET Intermediate Syntax
Understanding Delegates and Events
Events
Listing 4-1 Event demo
Microsoft Visual Studio 2010 a Beginner’s Guide
Learning Just Enough C# and VB.NET Intermediate Syntax
Delegates
Event, Delegate, and Handler Code Completion
Code completion for delegate assignment
Implementing Interfaces
Code completion for handler method creation
Creating an Interface
Listing 4-2 An interface
Making Classes Implement the Interface
Listing 4-4 Saving class that implements IAccount interface
Microsoft Visual Studio 2010 a Beginner’s Guide
Writing Code That Uses an Interface
101
Microsoft Visual Studio 2010 a Beginner’s Guide
103
Microsoft Visual Studio 2010 a Beginner’s Guide
105
Interface Snippet
C# interface snippet template
Listing 4-7 Creating and using an array
Applying Arrays and Generics
Coding Arrays
107
Microsoft Visual Studio 2010 a Beginner’s Guide
Coding Generics
109
Listing 4-8 Coding a generic list collection
Summary
Learning the VS 2010 Environment
This page intentionally left blank
Creating and Building Projects
113
Constructing Solutions and Projects
Creating a New Project
115
Navigating the Solution Explorer
Solution Explorer window
117
Examining Property Settings
Project Properties window
Assembly Name
Default Namespace
Target Framework
Output Type
Startup Object
Icon and Manifest
Assembly Information
121
Referencing Assemblies
File Properties window
Adding a .NET Assembly Reference
123
Managing Assembly References
Referencing Your Own Class Libraries
125
Using Code in Class Libraries
127
Listing 5-1 Class library code
Listing 5-2 Application code calling class library code
Building Solutions/Projects
Compiling Applications
129
Rebuilding Solutions/Projects
Cleaning Solutions/Projects
Managing Dependencies and Build Order
131
Project Dependencies window
Managing Compilation Settings
133
Microsoft Visual Studio 2010 a Beginner’s Guide
135
11 The VB Compile Options
Navigating a Project with Class View
12 The Class View window
Using the Class Designer
Class Designer Visualization
137
Class Designer Code Generation
14 Generating code with the Class Designer
139
15 Adding a new object to the Class Designer
Listing 5-3 Code generated from the Class Designer
141
This page intentionally left blank
Debugging with Visual Studio
143
Example Code for This Chapter
145
Listing 6-1 Example code for chapter
VB Module1.vb
147
VB Customer.vb
Development-Time Code Tools
149
Call Hierarchy window
Configuring Debug Mode
151
Build C# and Compile VB Properties tab
Debug Output folder
153
Debug properties
TIP
Setting Breakpoints
155
Creating a Breakpoint
A breakpoint
Customizing a Breakpoint
157
Options from the Breakpoint Context Menu
Stepping Through Code
Managing Breakpoints
159
Step Operations
Inspecting Application State
Locals and Autos Windows
Watch Windows
161
Immediate Window
11 The Immediate window
Call Stack Window
Quick Watch Window
163
Watching Variables with Pin To Source
13 The Quick Watch window
Working with IntelliTrace
165
Solving Problems with VS Debugger
15 The Debug History window
Program with Bugs
167
Customer Class
CustomerRepository Class
169
Program with Bugs
Microsoft Visual Studio 2010 a Beginner’s Guide
Finding the Bug
171
Cust.FirstName == Jean Cust.FirstName = Jean
173
16 The Memory window
Fixing the First Bug
Debugging and Resolving NullReferenceException Problems
175
Microsoft Visual Studio 2010 a Beginner’s Guide
177
Customers.IndexOfcust ?customers.IndexOfcust
Microsoft Visual Studio 2010 a Beginner’s Guide
179
Summary
Working with Data
181
Working with Databases
Introduction to Server Explorer
Creating a Database
183
Create New SQL Server Database
Adding Tables
185
Adding data to a table
Relating Tables with Foreign Keys
187
Managing a foreign key relationship
Configuring a foreign key relationship
189
Foreign key relationship Save warning message
A database diagram
191
Adding Stored Procedures
Listing 7-1 Stored procedure example
Configuring Database Options
193
Learning Language Integrated Query Linq
Querying Object Collections with Linq
195
Microsoft Visual Studio 2010 a Beginner’s Guide
197
Creating a Linq Projection with Anonymous Types
Using Linq to Sort Collection Results
199
Setting Up Linq to SQL
Handling Data with Linq to SQL
Working with the Linq to SQL Designer
201
12 The Linq to SQL Class Designer Properties window
Introduction to Querying Linq to SQL
203
Listing 7-3 Querying data with Linq to SQL
Here’s the output using my data
Performing Queries on Multiple Tables
205
Here’s the output
207
Microsoft Visual Studio 2010 a Beginner’s Guide
209
Output is
Inserting Data with Linq to SQL
Updating Data with Linq to SQL
211
Deleting Data with Linq to SQL
213
Summary
Building Programs with VS
This page intentionally left blank
Building Desktop Applications with WPF
217
Starting a WPF Project
Perform Screen Layout Use Controls Work with Data in the UI
219
A new WPF application project
Understanding Layout
Grid Layout
221
Adding columns and rows to a Grid
StackPanel Layout
Column and row sizing options
DockPanel Layout
223
WrapPanel Layout
DockPanel layout
Canvas Layout
225
Using WPF Controls
Managing Windows for Controls
227
Primary Windows for Working with Controls
Setting Properties
Handling Events
229
Listing 8-1 a WPF code-behind file
Private void button1Clickobject sender, RoutedEventArgs e
231
10 Readable button ID and event handler name
Coding Event Handlers
233
Working with Data in WPF
Setting Up a Data Source
235
11 Choosing a new data source
237
12 Selecting data objects
14 Changing the control type for a field
239
15 Controls bound via a data source
Microsoft Visual Studio 2010 a Beginner’s Guide
Configuring a ComboBox
241
Property Explanation
ComboBox Properties for Data Binding
Reading and Saving Data
243
Using the DataGrid
245
16 Displaying information in a Grid
Microsoft Visual Studio 2010 a Beginner’s Guide
247
This page intentionally left blank
ASP.NET MVC
249
Understanding ASP.NET MVC
Purpose of MVC Objects
Starting an ASP.NET MVC Project
251
A new ASP.NET MVC project
Running the default code produced by an ASP.NET MVC project
253
Creating the Models
Building Controllers
Listing 9-1 The HomeController class
255
Displaying Views
Looking Inside a View
257
Listing 9-2 a View’s Html
Organizing View Files
Assigning MasterPage Files
Listing 9-3 a MasterPage
259
Partial Views a.k.a. User Controls
Listing 9-4 Contents of a Partial View
261
Listing 9-5 Setting up routing
Managing Routing
263
Building a Customer Management Application
Creating a Repository
265
Listing 9-6 a repository for working with customer data
Microsoft Visual Studio 2010 a Beginner’s Guide
267
Creating a Customer Controller
Creating a new Controller
Displaying a Customer List
269
Listing 9-7 a Controller for displaying a list
Add View window
271
Listing 9-8 a Customer List View
Microsoft Visual Studio 2010 a Beginner’s Guide
273
Showing a list of objects
Adding a New Customer
Listing 9-9 Creating a new Customer object
275
Adding a new Customer
277
Listing 9-10 View for creating a new Customer
Microsoft Visual Studio 2010 a Beginner’s Guide
Updating Existing Customers
279
Listing 9-11 Methods for editing Customers
Microsoft Visual Studio 2010 a Beginner’s Guide
Deleting a Customer
281
Listing 9-12 The Delete Controller method
Listing 9-13 Deleting a Customer
283
Summary
Designing Silverlight Applications
285
Starting a Silverlight Project
287
Creating a new Silverlight application
Listing 10-1 Hosting a Silverlight application on a Web
289
Object Tag Parameters for Silverlight
Using Silverlight Controls
Navigating the Silverlight Designer
291
Playing Silverlight videos
Listing 10-2 Playing and stopping a video
293
Dim misPlaying As Boolean = False
Running Silverlight Out-of-Browser OOB
Silverlight properties
Out-of-browser settings
295
Choosing OOB
Deploying Silverlight Applications
297
Summary
Deploying Web Services with WCF
299
Key Skills & Concepts
Starting a WCF Project
301
Listing 11-1 a WCF service interface
Specifying a Contract with WCF Interfaces
Examining the VS-Generated Contract
303
Microsoft Visual Studio 2010 a Beginner’s Guide
305
Creating Your Own Contract
Listing 11-2 WCF service contract implementation
Listing 11-3 a custom type for a WCF service contract
307
Listing 11-4 Default WCF service implementation class
Implementing Logic with WCF Classes
309
Listing 11-5 a WCF service implementation
311
Microsoft Visual Studio 2010 a Beginner’s Guide
313
Hosting a WCF Service
Following General Hosting Procedures
Installing IIS 7 on Windows
315
Uninstall Or Change a Program window
Creating a Web Site on IIS 7 on Windows
317
Administrative Tools window
319
IIS Manager window
Add Web Site window
Deploying the WCF Service to IIS
321
Authentication And Authorization window
Listing 11-6 The WCF service address in app.config
323
Microsoft Visual Studio 2010 a Beginner’s Guide
10 The Publish WCF Service window
325
Communicating with a WCF Service
Creating a Service Reference
11 The Add Service Reference window
327
Microsoft Visual Studio 2010 a Beginner’s Guide
Coding Web Service Calls
329
Microsoft Visual Studio 2010 a Beginner’s Guide
331
Similarly, you can delete a Customer, as follows
13 The Service Reference Settings window
333
Listing 11-7 An application using a Web service
335
Deploying a Client That Consumes a Web Service
Configuration Files for Each Application Type
Creating a Web Service in a Web Site
Listing 11-8 Web service client configuration
337
Summary
Enhancing the VS 2010 Experience
This page intentionally left blank
Customizing Development Environment
341
Implementing Custom Templates
Creating New Project Templates
343
Modifying a Project
Exporting the Project Template
Choose Template Type window
345
Select Template Options window
Using the New Project Template
Creating New Item Templates
347
Creating an Item Template
Exporting the Item Template
Add the following code to the file C#
349
Select Item To Export window
Using an Item Template
351
Select Template Options window
Creating Custom Snippets
Creating a New Snippet
353
Examining Existing Snippets
Listing 12-1 Inside the for snippet
355
Creating New Snippets
357
Listing 12-2 a custom method snippet
Managing the Snippet Library
File Folders Holding Snippets
Using the Snippets Manager
359
Writing Macros
Recording a Macro
361
Parameter name
363
Saving a Macro
Editing Macros
365
Microsoft Visual Studio 2010 a Beginner’s Guide
367
Microsoft Visual Studio 2010 a Beginner’s Guide
VB doesn’t have problem that occurs in C# code
369
DTE.Windows.ItemCustomer.cs.Activate
Extending Visual Studio
371
Creating a Visual Studio Add-In
Running the Add-In Project Wizard
373
Selecting a Visual Studio Add-In in the New Project window
Select a Programming Language window
375
Enter a Name And Description window
Choosing ‘Help About’ window
Examining an Add-In Wizard Solution
377
Drilling into the Connect Class
IDTCommandTarget Interface
379
IDTExtensibility2 Interface
Listing 13-1 Skeleton code for the Connect class
381
Microsoft Visual Studio 2010 a Beginner’s Guide
Adding Functionality to an Add-In
383
Reviewing the OnConnection Method
Understanding OnConnection Parameters
OnConnection Method Parameters
385
Reviewing OnConnection Generated Code
Listing 13-2 The OnConnection method
Microsoft Visual Studio 2010 a Beginner’s Guide
387
Microsoft Visual Studio 2010 a Beginner’s Guide
389
Microsoft Visual Studio 2010 a Beginner’s Guide
Implementing the Exec Method
391
Listing 13-3 Implementing the Exec method
Microsoft Visual Studio 2010 a Beginner’s Guide
393
Microsoft Visual Studio 2010 a Beginner’s Guide
Setting Status with QueryStatus
395
Listing 13-4 The QueryStatus method
Microsoft Visual Studio 2010 a Beginner’s Guide
Deploying an Add-In
397
Listing 13-5 Contents of the *.AddIn file
Where to Go Next
399
Joe Mayo
Appendixes
This page intentionally left blank
Appendix a
403
VS 2010 XML Editor
XML Prefixes
Listing A-1 An XML document example
XML Elements
Attributes
405
Namespaces
Listing A-2 XML namespace example
Configuring XML Options
XML Menu
407
This page intentionally left blank
Appendix B
409
Listing B-1 a new Xaml file
Elements as Classes
Attributes as Properties
Executing the Xaml Document
411
Listing B-2 a Button with Content set as an attribute
Property Elements
Figure B-2 a Button with its Content attribute set as Text
413
Figure B-3 Button with Content property element set to Image
Markup Extensions
Listing B-3 Markup extension for using resources
415
Summary
Symbols
417
Microsoft Visual Studio 2010 a Beginner’s Guide
Index
Microsoft Visual Studio 2010 a Beginner’s Guide
Index
Methods, 72-80.See also specific methods
Vs. fields, 83 Properties folder, 117
Microsoft Visual Studio 2010 a Beginner’s Guide
Index
Microsoft Visual Studio 2010 a Beginner’s Guide
Top
Page
Image
Contents