Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[TUT] GUI of new generation (WPF) for VB.net && C#

Hello guys,

lately there is a lot of discussion about GUIs going on here, so I want to introduce you WPF (Windows Presentation Foundation), to create GUIs of new generation. WinForms are just obsolete and all its GUIs do look the same (or similar) no matter what you do. If you are VB6 coder, you can stop reading, because WPF if accesible only for .net developers (from 3.0 version I believe).

First some leeched theory from web (lazy to write it by myself), so here we go:
Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of both standalone and browser-hosted applications. The core of WPF is a resolution-independent and vector-based rendering engine that is built to take advantage of modern graphics hardware. WPF extends the core with a comprehensive set of application-development features that include Extensible Application Markup Language (XAML), controls, data binding, layout, 2-D and 3-D graphics, animation, styles, templates, documents, media, text, and typography. WPF is included in the Microsoft .NET Framework, so you can build applications that incorporate other elements of the .NET Framework class library. Well known Silverlight is just a subset of WPF, so whatever you saw in Silverlight, you can do for fat windows client and much more!

Ok, enough theory, right? It is really not that difficult as it may look like ...

QUICK TUTORIAL:
1. When creating an application, don't choose WinForms project, but WPF application:
[img]http://img210.imageshack.us/img210/2002/projectz.jpg[/img]

2. After the project is created, the screen looks almost the same as in WinForms. You have your default dialog (form) prepared for you and you can drag-and-drop controls from the toolbox. The same as WinForms, right? Not a big deal here ... The only difference is that the form code is in XAML, as seen below:
[img]http://img833.imageshack.us/img833/8800/project2k.jpg[/img]

3. Next, I really advise you to download MS Expression Blend (4.0 current version). It's a graphic tool something between Photoshop and Visual Studio for creating neat GUI and controls. Although you can do it all in Visual Studio only, with Blend, you can do much much more. I own MCTS WPF certificate, so I know what I am telling you. You can run both Visual Studio and Blend at the same time with the same project open. This tools can work together.
This is Blend:
[img]http://img299.imageshack.us/img299/2465/blendp.jpg[/img]

This is it, with WPF, you divide the presentation layer and the application logic, which is totally the same as you are used to from WinForms. With WPF you just can create everything, want a button looking like a star with all properties like the WinForms button? No problem, just draw it in Blend ... I am not mentioning animations, because this is supposed to be just a basic tutorial, but yes, with WPF you can create animations easily as well. On the bottom on this TUT you will find some e-books if you are interested ...

Now, some gallery from google:
this is my favourite, with WPF you can insert to combobox anything you want, not only text ...
[img]http://img697.imageshack.us/img697/8107/combob.png[/img]
[img]http://img135.imageshack.us/img135/1147/18662968.jpg[/img]
[img]http://img201.imageshack.us/img201/5918/92242537.jpg[/img]
[img]http://img543.imageshack.us/img543/8804/77064683.jpg[/img]

Ok guys, that's all from me, hope at least someone will try it and use it in the future 🤝

E-books as promised:

Addison Wesley Essential Windows Presentation Foundation
Apress Pro WPF in C Sharp
Apress Pro WPF Windows Presentation Foundation in dot NET 3.0
Sams Windows Presentation Foundation Unleashed

PS: this books don't cover .net 4.0 stuff, but it is pretty useless for you ...
Blend is awesome! ^^
You can even choose a 3d model for the interface.
WPF gives me a headache. It's so much more.. dynamic then Windows Forms but there isn't nearly as much material to learn from on the web (opposed to winforms). Another downside is how much memory it sucks up; WPF spawns like 30 threads to handle UI stuff.
(Oct 5, 2010 06:12 AM)6e756c6c Wrote:  WPF gives me a headache. It's so much more.. dynamic then Windows Forms but there isn't nearly as much material to learn from on the web (opposed to winforms). Another downside is how much memory it sucks up; WPF spawns like 30 threads to handle UI stuff.

true, but you can do miracles with it and the memory downside is not such a problem this days (if you are not doing some big animation). the number of tutorials on the web is growing rapidly, also you have MSDN forum 😖
I downloaded blend like 3 days ago and I have no clue how to use it. xD
XAML!!!XAML!!! plus c# and WPF ,put all that in VS and Blend.This is how true .net coders roll.
I believe that only the controls themes are different?
any way nice share!
thanks for the tut been looking for this nobody tells me anything o-o


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by ElectronMar 15, 2021 11:05 AM 4 459 Mar 15, 2021 11:05 AM
Last Post: Jaque
[C#] by going clearJan 18, 2021 06:29 AM 2 167 Jan 18, 2021 06:29 AM
Last Post: Narwin
[C#] by ObistoneOct 17, 2020 12:05 PM 10 426 Oct 17, 2020 12:05 PM
Last Post: Narwin