|
|
|
|
|
Home
»
WPF
»
Getting Started with Windows Presentation Foundation
|
|
|
|
Author Rank :
|
|
|
Page Views :
|
1216
|
|
Downloads :
|
0
|
|
Rating :
|
Rate it
|
|
Level :
|
Beginner
|
|
|
Getting Started with Windows Presentation Foundation
This tutorial provides a simple introduction to the development of a Windows Presentation Foundation (WPF).
-
Create the Application Code Files
In this step, you create the application infrastructure, which includes an application definition, two pages, and an image. Create a new XAML markup file called App.xaml. This file defines a WPF application, and you also use it to specify the UI to automatically show when the application starts; in this case, HomePage.xaml (created in the next step). Your XAML markup should look like this: XAML
<Application x:Class="Application" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml"> <Application.Resources> </Application.Resources> </Application>
-
Create a new XAML markup file called HomePage.xaml, which will be the first page that is displayed when the application is launched. HomePage.xaml will show a list of people from which a user can select a person to show an expense report for. Add a Page element to HomePage.xaml, with the following configuration:
-
The title bar of the browser is "ExpenseIt".
-
The width of the browser is 550 device-independent pixels.
-
The height of the browser is 350 device-independent pixels.
-
The title of the page is "ExpenseIt - Home".
-
Create a new code file called HomePage.xaml.cs. This file will be a code-behind file that contains code to handle the events declared in HomePage.xaml. Your code should look like this:
C#
using System; using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; namespace ExpenseIt { public partial class HomePage : Page { public HomePage() { InitializeComponent(); } } }
-
Create a new XAML markup file called ExpenseReportPage.xaml. Add a Page element and set "ExpenseIt - View Expense Report" as the page title. This page will show the expense report for the person that is selected on HomePage.xaml. Your XAML markup should look like this:
XAML
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ExpenseIt.ExpenseReportPage" Title="ExpenseIt - View Expense Report"> </Page>
-
Create a new file called it ExpenseReportPage.xaml.cs. This file will be a code-behind file that binds expense report data to the UI defined in ExpenseReportPage.xaml. Your code should look like this:
using System; using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; namespace ExpenseIt { public partial class ExpenseReportPage : Page { public ExpenseReportPage() { InitializeComponent(); } } }
Add an image called watermark.png to the same folder as the five code files that you created in the preceding steps. You can either create your own image, .
|
|
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post
Here.
|
|
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
|
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
|
|
|
|
|
|
|
|
|
|
|
|
|