Everyone has to check out this new site from the WWE (Wrestling) built using silverlight it is apsolutly awesome. It has some cool vids on there Wrestle Mania 3! Check it out!
http://www.wwe.com/inside/silverlight/launch/
Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts
Thursday, 6 September 2007
Tuesday, 28 August 2007
WPF Calculator
In my last post I went through creating my first application in WPF and straight away I started thinking about creating a much more visually attractive application, so I decided to create another basic application, this time a simple calculator.

Using Orcas Beta 2 I was able to create a WPF form with 2 text boxes for user input, a combo box, button and a label for the result of the calculations.
I first started out with the combo box displaying text to signify different calculations (e.g. +, -, /,*) however as I was making the rest of the application found myself getting more confident and decided to add images to the combo box so that a user can select an image representing there choice. Implementing this was much easier that I first thought it would be and using only a couple of lines of code in the XAML file and altering some of the code behind file I was able to use the image combo box to select the type of calculation. The XAML for this is:

<ComboBox Margin="40,107.457,0,79.968" Width="120" Name="comboBox1" HorizontalAlignment="Left">
<Image Name="add" Source ="images\add.jpg" />
<Image Name="minus" Source ="images\minus.jpg" />
<Image Name="multiply" Source ="images\multiply.jpg" />
<Image Name="divide" Source ="images\divide.jpg" />
</ComboBox>

Using Orcas Beta 2 I was able to create a WPF form with 2 text boxes for user input, a combo box, button and a label for the result of the calculations.
I first started out with the combo box displaying text to signify different calculations (e.g. +, -, /,*) however as I was making the rest of the application found myself getting more confident and decided to add images to the combo box so that a user can select an image representing there choice. Implementing this was much easier that I first thought it would be and using only a couple of lines of code in the XAML file and altering some of the code behind file I was able to use the image combo box to select the type of calculation. The XAML for this is:

<ComboBox Margin="40,107.457,0,79.968" Width="120" Name="comboBox1" HorizontalAlignment="Left">
<Image Name="add" Source ="images\add.jpg" />
<Image Name="minus" Source ="images\minus.jpg" />
<Image Name="multiply" Source ="images\multiply.jpg" />
<Image Name="divide" Source ="images\divide.jpg" />
</ComboBox>
And in the code for this to find which of these images your user selected simply find the index of the items in the combo box.
All the images that I have used in the combo box were created in Expressin Design and Exported as jpg files. With creating the images myself I was able to directly match the hex color value for the rest of the application to this creating a unified feel to the program.

Overall I dont think it was a bad effort at all for an hours work, an experienced programmer would be able to create some amazing things with WPF can't wait till it hits the mainstream and all released products look this good.
WPF "Hello, World"
So I managed to complete the WPF introduction course which I last posted about and after doing this I thought I would like to create a simple application using XAML and WPF to feel a little more at home with the whole subject, so I decided to download me a copy of Orcas Beta 2 Express and create a Hello World App.
Hello World applications are normally the first application (if you can even call them that) that most people will make when they start looking at a new programming language or programming concept. So heres how I went about creating my first WPF application.
I used Orcas, which is really nice I love the split layout that is used to display the design in the top half of the screen and the XAML code in the bottom section, this reminds me of using Expression Web and how the design and code is split on a single screen making it easy to tweak little bits of the program without constantly switching to a code view. However to see the code behind file for the application (much like the code behind files in ASP.NET) you have to open a new tab to get to this.

So getting started I just dragged and dropped a button and text box onto the form, this like i said before generates the XAML in the bottom half of the screen, so you can see how buttons are made in XAML. The XAML is really easy to understand and if like myself you have had some previous experience with XML you will find it pretty straigh forward.
Once I have my form layout how I want it, I then have to get the XAML button to respond to an event, this can either be done just like in a C# windows application by double clicking on the button or it can be done in the XAML code itself. To add an on click event you simply add a "click" attribute to the button tag.
For this event handler in the code it is extremly simple to display the desired text in the text box done just how you would if you were using any other language.
private void button1_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = "Hello, World";
}
This then just simply displays the text "Hello, World" in the text box we created in design view. Now we can run the code and see the amazing aplication in all its glory.
I am hoping to get a little time to play about with WPF before I have to start uni so hopefully will start to make some better appliations than this.
Hello World applications are normally the first application (if you can even call them that) that most people will make when they start looking at a new programming language or programming concept. So heres how I went about creating my first WPF application.
I used Orcas, which is really nice I love the split layout that is used to display the design in the top half of the screen and the XAML code in the bottom section, this reminds me of using Expression Web and how the design and code is split on a single screen making it easy to tweak little bits of the program without constantly switching to a code view. However to see the code behind file for the application (much like the code behind files in ASP.NET) you have to open a new tab to get to this.

So getting started I just dragged and dropped a button and text box onto the form, this like i said before generates the XAML in the bottom half of the screen, so you can see how buttons are made in XAML. The XAML is really easy to understand and if like myself you have had some previous experience with XML you will find it pretty straigh forward.
Once I have my form layout how I want it, I then have to get the XAML button to respond to an event, this can either be done just like in a C# windows application by double clicking on the button or it can be done in the XAML code itself. To add an on click event you simply add a "click" attribute to the button tag.
So we now have:
click = "button1_click"
added to the attribue list for the button tag.
For this event handler in the code it is extremly simple to display the desired text in the text box done just how you would if you were using any other language.
private void button1_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = "Hello, World";
}

This then just simply displays the text "Hello, World" in the text box we created in design view. Now we can run the code and see the amazing aplication in all its glory.
I am hoping to get a little time to play about with WPF before I have to start uni so hopefully will start to make some better appliations than this.
Subscribe to:
Posts (Atom)