Monday, October 13, 2008

Basic differences between Windows and WPF application:


As a beginner to WPF having worked on Windows application, some of the basic differences that I came across between the two are:
1. The Windows class derives from System.Windows.Forms namespace whereas a WPF class derives from the System.Windows.Window namespace
2. The program.cs file was used to specify the startup class in a Windows app but in a WPF app, the Startup Uri in the App.xaml can be used to specify the startup class.
3. The name attribute for any control was mandatory in a Windows app, but is not mandatory for a WPF application. Eg: If I have 2 buttons in a WPF form without any name property, if I add a click event for the 2 buttons the events generated are
private void Button_Click(object sender, RoutedEventArgs e)
{
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
}
4. If you noticed in the previous example, the RoutedEventArgs is something new compared to the EventArgs in a Windows App. So, what is the difference between the two?
A Routed event can not only occur on the object that initially raises it but also on objects related to it i.e. the event can be passed on.
Some good links to get started with WPF are
http://aspalliance.com/articles/LearnWPF.aspx
http://windowsclient.net/

No comments: