Freigeben über


WPF... Some Initial thoughts

So now that I have been playing around for a while with WPF I have finally started to wrap my head around the shift in the Design/Development flow. I have actually found the easiest way to describe how WPF works, is to view it as a very similar paradigm for desktop apps, as ASP.Net is for web apps. With ASP.Net we have a page that controls the UI, which is the .aspx page which gets rendered as HTML for the end user. For all the logic that reacts to the users interaction on the page, we have the .aspx.cs (or aspx.vb if you are using Visual Basic) which holds all the code, also known as the code behind page. WPF gives us a very similar experience for our Desktop apps. We have the XAML file which describes the UI in a very declarative way very similar to working with HTML or XML, and then we have the code behind page the XAML.cs that holds the actual logic. Very similar to asp.net this allows me to very clearly and efficiently separate my presentation from my logic. As long as I use a common naming convention in my UI, I can change the look and feel all I want without having to affect the back end logic.

Where WPF further draws comparison to ASP.Net is in the ability to apply themes and styles to my application UI. I can define styles inline or in separate files in a manner similar to how I do it for web applications. Though in WPF I am not using CSS or .skin files, the overall system is very similar. Where WPF really shows it's power however is in the ability to describe the UI not only using controls, but also by using the built in Drawing functionality and classes. In the past to truly customize your UI in desktop applications you ended up doing a lot of GDI work and for the most part re-writing the render behavior for your controls. WPF gives us the ability to use declarative markup to describe the appearance and behavior of our controls. Once you get familiar with the Drawing APIs and Objects in WPF, you will find it much easier to work with than GDI ever was. And if you still don't want to do even that much work, you have tools like Expression Blend that will allow you to draw your UI and apply animations etc... in a very designer familiar environment, and it will output all the XAML for you. While these tools do save time, I highly recommend doing some work directly in XAML to get the hang of it. This will definitely help when you are looking for a very specific affect or outcome and having a hard time trying to get some of the tools to do it for you.

 Having spent some time working strictly in XAML lately to force myself to get used to it and avoid using any of the tools that will generate it for me has really helped a lot. For those of you who are interested I will start posting some simple step by step tutorials soon focusing on using XAML to create basic UI elements and effects. Till next time...

Comments