1.Difference
between Custom Control and User Control in Silverlight
2.Difference
between DataContext and ItemsSource property in Silverlight
-
S.No Custom ControlUser Control1A loosely coupled control w.r.t code and UIA tightly coupled control w.r.t code and UI2 Derives from ControlDerives from UserControl3 Defines UI in the ResourceDictionaryDefines UI as a normal XAML4 UI can be skinableChild controls can skinable only5 Has Dynamic layoutHas static layout6 UI can be changed in different projectUI is fixed and can't have different look in every project7 Has full toolbox supportCan't be added to the toolbox8 Defines a single controlDefines a set of controls9 More flexibleNot much flexible like Custom Control10 Requires in depth knowledge of Silverlight UI ModelDoes not require depth knowledge of UI Model
-
S.No DataContext propertyItemSource property1DataContext expects an object typeItemsSource expects IEnumerable type objects2 DataContext is a dependency property is exposed by FrameworkElement base classItemsSource is defined by the ItemsControl class. All the descendants of FrameworkElement can utilize the DataContext property and set an object to its value.Note: But we can only set a type of IEnumerable(or instance of class that derives from).3 DataContext does not generate template, it only used to hold common data for other controls to bind.In terms of ItemsSource property, it is mainly used to generate template regardless of you set it in XAML or in the code behind.4 DataContext is mainly used to hold common data that other child want to share. Thus it can be inherited by other child elements without problem.But for ItemsSource, it is not used to share data in the visual tree. It is only valid for the element that defined. There is still one thing to be noted is that the child element can override the DataContext of the perent DataContext no mater directly or indirectly.
Example(s):
Suppose
we have a Person Class which has a property Name. Now in Xaml we can
say like:
If
you run this code in the ListBox you will get to see values depending
on List object. But if we change the ItemsSource to
DataContext then you will be not able to see anything because
DataContext doesn't generate templates in any cases. If you set
datacontext still you have to set the ItemsSource property like this:
Summary:
In
a word, if we have several child elements that will share a common
data source, we can set DataContext property for the parent elements.
And we use ItemsSource for ItemsSource in most cased to generate
template. Like:
3.Difference
between Silverlight and Flex
-
S.No SilverlightFlex1Execution Mechanism:Power of Native execution of CLR instead of Flash's Action Script InterpretatorExecution Mechanism:Slow execution for iterative executions2 Editing facility:Expression Blend is really cool and more advanced editor then Flex BuilderEditing facility:Flex Builder is not that much good editor when compare with Expression Blend3 Multilanguages Support:Power of other languages, provides Generics and Linq etcMultilanguages Support:No generics, No other languages, No linq.4 Threading and Asynchronous Tasks:AvailableThreading and Asynchronous Tasks:Unavailable5 Form layouting and binding:Binding in Silverlight is way more cumbersome.Binding requires component naming and does not support instance expressions like flex does, though two way binding is good in silverlight but you have to write long codes for multiple bindings for one math expression.Form layouting and binding:Better in Adobe Flex.The most easy way to create new components, you can have mxml derive from any control and extend them with extensive binding.6 Where primarily used:Silverlight is used for extremely rich graphics and animationWhere primarily used:We use flex for data applications, those are simple form processing applications7 Search Engine Friendly:XAML is Search Engine FriendlySearch Engine Friendly:MXML markup language is not Search Engine Friendly8 Client / Server Technology:Silverlight can be developed for a server or client environment.Client / Server Technology:Flex is a client based application tool9 Release Date:Release Date:Adobe Flex was originally released in 2004 by Macromedia. The third version (Flex Builder 3) became available in 2008.10 Language Differences:Language Differences:Adobe Flex uses MXML markup language and actionscript to build layout/graphic user interfaces. To create components, it works with ActionScript (the object oriented Flash language). After the code is completed, it needs to be compiled by the Flex Application Server.11 Data Transfer:Data Transfer:12 Debugging:Debugging:13 Webservice Access:Webservice Access:14 Componenet Size:Component Size:
No comments:
Post a Comment