He tries however to compare WPF to other technologies and I don't understand what he is saying. Perhaps someone here can explain things. I will summarize here what the book says and if necessary I will quote the book but hopefully this is close enough to what the book says. So the following is essentially what it says but this is my version of it:
The following is my version of what the book says:
CSS can be used to create a UI style for a TextBox for use throughout a web. That is impossible to do using the basic tools of client technologies such as Windows Forms and Java. In other words, it is not possible to define a style for a UI control for Windows Forms. Using Windows Forms, if we want to create a TextBox with a specific border color and shape then we must make a custom TextBox. Using WPF, it is possible to make a TextBox change it's background color when it gets the focus.
The preceding is my version of what the book says.
The book is saying that the basic tools of client technologies makes it difficult to do things like that. I do understand that a WPF TextBox has more capabilities than a Windows Forms TextBox. That however is not what the author is saying; he is saying that there is a basic difference that prevents a Windows Forms application from using a style throughout an application; something that is easy for WPF but not easy for Windows Forms.
First, note that it is totally possible to change a BackColor property of a Windows Forms's TextBox object when it receives and loses focus, correct? So that seems to be the same for WPF and Windows Forms. A Windows Forms application can derive a class from the TextBox class that changes the BackColor property in that manner and use the derived class throughout the application. So I don't understand the significance of that part of what the book says.
As I said, a WPF TextBox has more capabilities than a Windows Forms TextBox. The thing I am not sure of is which of the two that the book is saying is easier to do with WPF:
- adding capabilities to a control that it does not already support and using that modification throughout an application
- use a control with some of it's properties of existing capabilities set to specific values and use that throughout the application
But wait, there is more. Using Windows Forms, it is easy to create a UserControl. It is entirely possible to create a UserControl with a TextBox in it and then draw a custom border around the TextBox, correct? And then a Windows Forms TextBox can have as much capabilities for a custom border as a WPF TextBox, correct? A Windows Forms UserControl can easily be used thoughout a Windows Forms application, correct?

Mahesh ChandPosted Jul 3, 2011, 4:33 PM
Resources in WPF
Styles in WPF
Sam HobbsPosted Jul 3, 2011, 4:54 AM
So the question is how is it that it is easier to apply a style throughout an application using WPF compared to Windows Forms. The question is not if WPF controls have more features; the question is how is it easier to use controls throughout an application with a modified style using WPF compared to Windows Forms.
So I suppose I have gotten to the point where I need to learn more about WPF so I can answer this question myself.
Mahesh ChandPosted Jul 3, 2011, 2:15 AM
I have been working with Windows Forms since 1999 and migrated to WPF. My GDI+ book is basically on Windows Forms (GDI+).
WPF controls including TextBox definitely provide more functionality than Windows Forms controls. But, the author is also correct. In Windows Forms, you can't set styles of controls. That is because of the GDI+ model. GDI+ has to render everything using GDI. WPF, however uses a new model (not GDI) and provides many new features and one of them being styles. Now, similar to CSS on the Web, we can use resources in WPF. We can create a resource, for example, MyBackgroundColor and apply that to any control like we do on the Web. This is just not possible in Windows Forms.
Heck, if you need to change the border of a ListBox or display background as an Image of a ListBox in Windows Forms, we will have to freaking do owner-draw and so many other things. Still, Windows Forms rendering is not efficient.
I hope it helps :)
Sam HobbsPosted Jun 30, 2011, 1:03 PM
Perhaps the author made the comparison of WPF compared to other technologies too soon before explaining WPF well enough. As it exists, the comparison seems inaccurate. I sent a comment to the author and he said that if we inherit from TextBox it is not easy to do the same thing. It is not clear to me however what that same thing is.
Deriving from a UserControl can be amazingly easy. It will be amazing if it is possible to add function (capabilities) to WPF controls easier than when we use a Windows Forms UserControl to add function to Windows Forms controls.
Dan SullivanPosted Jun 30, 2011, 11:48 AM
From my understanding of WPF, the second of your statements is true. XAML allows for CSS like definitions, so that we as developers can change the look of a certain component throughout the entire application. In Windows Forms, changing the properties of a TextBox is done mostly on an instance by instance basis. You are right, you can derive a UserControl based on the TextBox and then use that throughout your application. The idea with WPF is that you don't have to take that extra step. Since it takes a much more HTML/CSS approach, cosmetic changes are easier and quicker to implement and possibly change later. This is only touching the power of WPF and I hope that you continue to read the book.