My Hello World in WPF 3.5

Vuyiswamb
Posted by in WPF category on for Beginner level | Views : 18394 red flag

Technology is growing, everyday you will hear that there is a new version of something and you will wonder if we will ever stop learning. If you are a Microsoft developer you will always buy books because almost every three or two years they bring something and when you are still busy trying to master the current technology, they introduce something new that is better than this. The gap between .net 2.0 and 3.5 was enough to allow developers to catch up. Well I got affected by that but I kept on touching the chapters of those technologies. I was impressed by all these niceties but I could not have time to explore them all. I came across a WPF and I was impressed by the UI, even if you create a small hello world. I would like to share a small hello world about WPF.

 

Introduction

Technology is growing, everyday you will hear that there is a new version of something and you will wonder if we will ever stop learning. If you are a Microsoft developer you will always buy books because almost every three or two years they bring something and when you are still busy trying to master the current technology, they introduce something new that is better than this. The gap between .net 2.0 and 3.5 was enough to allow developers to catch up. Well I got affected by that but I kept on touching the chapters of those technologies. I was impressed by all these niceties but I could not have time to explore them all. I came across a WPF and I was impressed by the UI, even if you create a small hello world. I would like to share a small hello world about WPF.

 

What is WPF

Rob Eisenberg put it clear and said Windows Presentation Foundation (hereafter referred to as WPF) is a new API for creating graphical user interfaces for the Windows platform. It is an alternative to WinForms that further empowers developers by providing an API capable of taking full advantage of the multimedia facilities of the modern PC. Unlike WinForms, it does not wrap Win32 but it is completely new, built from the ground up using .NET. The fundamental power of WPF comes from the fact that it is vector based, hardware accelerated and resolution independent.

 

Using the code

The code will be done in C#.

Start

Open your Visual studio 2008 and create a new Project and you will see a dialog like this

 

Choose WPF Application and give your project a meaningful name, mine is “Myhello_world” and click ok. At first you might get some errors on your xaml about windows tag. What you need to do is to make sure that you have imported all the required references. Check mine and compare them with yours

 

After you are done go to your window1.xaml and you will see a designer. 

 

 

 

Add a button from your toolbox and a textbox. Select the button and select its properties and in the properties go to the events and look for the click event like this

Double click and you will be sent to the code.

 

        private void button1_Click(object sender, RoutedEventArgs e)

        {

            textBox1.Text = "Hello world";

        }

 

Write your code to look like the above code. Run your Application and this is what you will see

 

 

The UI is different from the previous GUI that we used to work with in the win applications. This is only the Beginning to show you how things are in WPF. Now what could be done in web pages at ease (2D, 3D) it can be done here at ease too. Now click on the send button and you will see the following

 

 

This is not the end of what WPF can do. Check the Following examples what WPF can do

 

http://www.wpftutorial.net/ToolTip.html

 

         

Conclusion

I promise to share will share more, when I get more time to look at the nice things in wpf.

Thank you

 

Page copy protected against web site content infringement by Copyscape

About the Author

Vuyiswamb
Full Name: Vuyiswa Maseko
Member Level: NotApplicable
Member Status: Member,MVP,Administrator
Member Since: 7/6/2008 11:50:44 PM
Country: South Africa
Thank you for posting at Dotnetfunda [Administrator]
http://www.Dotnetfunda.com
Vuyiswa Junius Maseko is a Founder of Vimalsoft (Pty) Ltd (http://www.vimalsoft.com/) and a forum moderator at www.DotnetFunda. Vuyiswa has been developing for 16 years now. his major strength are C# 1.1,2.0,3.0,3.5,4.0,4.5 and vb.net and sql and his interest were in asp.net, c#, Silverlight,wpf,wcf, wwf and now his interests are in Kinect for Windows,Unity 3D. He has been using .net since the beta version of it. Vuyiswa believes that Kinect and Hololen is the next generation of computing.Thanks to people like Chris Maunder (codeproject), Colin Angus Mackay (codeproject), Dave Kreskowiak (Codeproject), Sheo Narayan (.Netfunda),Rajesh Kumar(Microsoft) They have made vuyiswa what he is today.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)