开发者

wpf templates styles usercontroles what are the relationships between?

for the last week i have been trying to study WPFi took a two days course where they tryied to run all ov开发者_运维技巧er the materiel and i just got confused can someone set my record strighet and

explain me where to use each one ? what MVVM got to do with all of this ?


Okay - this is really enough stuff to fill a month or so of course... but I'll try to get the ball rolliing:

WPF uses what they call 'lookless' controls which means that each control has a ControlTemplate that designates how it behaves (This is where you define what happens when the mouse is above the control and so on) - and then it has a DataTemplate that determines how it behaves with the data it is bound to (ie. which properties to show and how). Either template can be exchanged with a new one totally altering the look without affecting the other. To further complicate matters - we have ItemTemplates that are used with ItemsControls (ListBox, ListView, DataGrid and a few others) - these determine how the data is visualized within the ItemsControl.

A UserControl just a container (that usually has no or little layout) that contains a number of other Controls.

Styles on the other hand is a collection of alterations of one or more controls (it can be used by several Controls of the same type) - In styles you can set a number of properties for a given type of control as well as Triggers that react to changes in propeties and/or the Data to which the control is bound.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜