Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Architecture
ASP.NET
ASP.NET MVC
ASP.NET WebForms
B2B (Business Integration)
BizTalk
Book Excerpts
Build and Deploy
C#
C++
Code Contracts
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Design Patterns
Development Process
Display Technologies
Distributed Computing
DotNetNuke
DSL
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Graphics
Internet Explorer 8.0
Interviews
iPhone
Java
Java Script
jQuery
LINQ
Linux
Mac OS X
MDX
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
Network
NHibernate
Object Oriented Development
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
Podcasts
Post Mortem
PowerPoint
Print/Output
Product News
Product Reviews
Project Management
Python
Q&A
Reporting Services
REST
RIA Services
Ruby
Search
Security
Services
SharePoint
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server CE/AnyWhere/Mobile/Compact
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
Tips
UI Design
UML
User Groups
VB Script
VB.NET
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WF
Whitepapers
Windows 7
Windows Azure
Windows Live
Windows Server
Windows Vista
WinForms
Workflow
WPF
XAML
XML
XNA
XSLT



ESDC


 


State of .NET

Reader rating:
Click here to read 2 comments about this article.
Article source: CoDe (2006 - Mar/Apr)


Article Pages:  1  2 3 4 - Next >


An Overview of Windows Presentation Foundation

By now you should have heard of several new acronyms that are usually associated with Windows Vista (codenamed Longhorn). These acronyms include WinFX, WinFS, WCF (Windows Communication Foundation; codenamed Indigo), and WPF (Windows Presentation Foundation; codenamed Avalon). In recent months, there has been a lot of buzz going around WPF, which is one of the core components of WinFX. In this article, I will bring you on a whirlwind tour of what WPF is and how you can start preparing for Vista by developing applications today using the available SDK.

Why Windows Presentation Foundation?

Windows Presentation Foundation (WPF) is the new graphics subsystem in Windows Vista that will enable developers to build applications that provide breakthrough user experiences. If you look at the applications in use today, they are either Windows applications or Web applications. While Windows applications offer immensely rich client functionality, deploying Windows applications require considerable resources and make maintenance a constant challenge. On the other hand, Web applications offers ease of deployment and maintenance, but do so at the expense of increased complexity in the development process (since the Web is stateless) as well as less-than-ideal platform integration.

"
It is the goal of WPF to offer a development platform that offers the best of both worlds, allowing administrators to deploy and manage applications securely.
"

Microsoft’s goal when they created WPF was to offer a development platform that offers the best of both worlds, allowing administrators to deploy and manage applications securely.

Besides the rapid evolving of application development technologies, hardware advances have also been moving at a rapid rate. In particular, the processing power of video cards has been improving at a much more rapid rate than developers can make use of. Increasingly, computers are equipped with an over-powered graphics subsystem that is under utilized. Applications could jolly well take advantage of the power of these graphics cards (such as for 3-D processing) to enhance the user experience.

And this is exactly the aim of WPF-that is, to take advantage of the under-utilized power of the video card and use it to enhance the user experience of Windows applications. WPF uses Direct3D for vector-based rendering, enabling applications to incorporate a wide assortment of media such as 2-D, 3-D, audio, text, video, animation, etc.

Building User Interfaces using XAML

In WPF, Microsoft introduces a new language for creating WPF applications-XAML (Extensible Application Markup Language). Using XAML, developers can create UIs declaratively using XML elements and attributes. This provides for a clean separation of application logic and the UI of the application, allowing interface designers to use external tools (more on this later) to design the UI and then wire up with the code-behinds using .NET languages.

XAMLPad

To get developers started with XAML, Microsoft provides a useful tool known as XAMLPad. XAMLPad is a XAML editor that allows you to quickly preview your UI. To use XAMLPad, go to Start, choose Programs, choose Microsoft Windows SDK, then choose Tools, and finally choose XAMLPad. Figure 1 shows the various components in XAMLPad.

Click for a larger version of this image.

Figure 1: The various components in XAMLPad.

XAMLPad offers the following functions:

  1. Auto Parse - The Preview Pane (7) will be updated as you type your XAML code in (8)
  2. Refresh - Refreshes the Preview Pane (7)
  3. Changes the font in the Code Edit Pane (8)
  4. Changes the font size in the Code Edit Pane (8)
  5. Hides the Code Edit Pane (8)
  6. Changes the scaling factor of the Preview Pane (7)
  7. Preview Pane
  8. Code Edit Pane
  9. Status bar

To see the XAMLPad in action, let’s populate the Edit Pane with some XAML code (Listing 1).

Figure 2 shows the resulting UI.

Click for a larger version of this image.

Figure 2: Using XAMLPad to preview XAML code.

Notice that the XAML code looks like HTML as all UI controls are defined declaratively.

XAML supports a few layout patterns for UI controls, and the one just shown uses the Canvas layout. The Canvas layout pattern is similar to what you have today in Windows Forms. The controls in a Canvas layout are positioned using the x and y coorindates. The Canvas layout is useful in cases where you need to precisely position the various controls on the UI.

You may have noticed that in the Canvas element there is a LayoutTransform attribute. This attribute allows you to scale the output by simply specifying the scale factor. For example, if you specify a factor of 0.5 (LayoutTransform="scale 0.5"), then the entire Canvas layout would shrink by 50% (Figure 3).

Click for a larger version of this image.

Figure 3: Using LayoutTransform to shrink the output.

&

By: Wei-Meng Lee

Wei-Meng Lee is a technologist and founder of Developer Learning Solutions (http://www.learn2develop.net), a technology company specializing in hands-on training on the latest Microsoft technologies.

Wei-Meng speaks regularly at international conferences and is the author of ASP.NET 2.0: A Developer’s Notebook and Visual Basic 2005 Jumpstart (both from O'Reilly Media, Inc).

Wei-Meng is currently a Microsoft Device Application Development MVP.

Contact Wei-Meng at weimenglee@learn2develop.net.

Fast Facts

In the current version of Visual Studio 2005 (Release Candidate at the time of writing), there is no visual designer for WPF applications. That is to say, you cannot drag and drop controls from the Toolbox onto the design surface of a WPF application. You have to manually code using XAML (see Figure 9). However, it is expected that in the near future Microsoft will provide a visual designer for WPF applications.



Listing 1: Sample XAML code
<Canvas 
 xmlns="http://schemas.microsoft.com/winfx/avalon/2005
 Background="Ivory" LayoutTransform="scale 1">
   <Label 
      Canvas.Top="10" Canvas.Left="10" 
      BorderBrush="Crimson" BorderThickness="1">
      Image Source
   </Label>

   <TextBox Canvas.Top="40" Canvas.Left="10" >
   </TextBox>

   <Button Canvas.Top="40" Canvas.Left="120" 
      Height="25">OK</Button>
   <Image Width="400" Canvas.Top="75" 
      Canvas.Left="10" >
      <Image.Source>
         <BitmapImage UriSource="C:\Sunset.jpg" />
      </Image.Source>
   </Image>
</Canvas>


Article Pages:  1  2 3 4 - Next Page: 'Layouts' >>

Page 1: An Overview of Windows Presentation Foundation
Page 2: Layouts
Page 3: Programmatically Generating the WPF UI
Page 4: Imaging

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
3.7 out of 5

35 people have rated this article.

      ESDC

 

CODE TRAINING