Go Back   TechArena Community > ARENA > Guides & Tutorials
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



XAML Processing Differences Between Silverlight 3 and Silverlight 4

Guides & Tutorials


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-08-2010
Member
 
Join Date: Feb 2008
Posts: 137
XAML Processing Differences Between Silverlight 3 and Silverlight 4
  

Silverlight uses XAML analyzers different depending on whether the destination of the application is Silverlight 3 or Silverlight 4. For compatibility, the two analyzers exist simultaneously in the Silverlight core libraries 4. Applications that have been compiled for Silverlight version 3 and have used this version as the target specific analyzer Silverlight XAML version 3. Applications that have been compiled for Silverlight version 4 and have used this version as the target specific analyzer Silverlight XAML version 4. This subject illustrates the XAML processing differences between Silverlight 3 and Silverlight 4.

Syntactic variations

Mixed Elements and proprietary content

Silverlight 3 sustains mixed content elements and property in XAML. On the other hand, the Silverlight XAML 4 and [MS-XAML] does not support them. For example, the subsequent XAML code can be scrutinized in Silverlight 3 but not Silverlight 4:

Code:
X:Name="BorderLayout"> <Grid
     <TextBlock>
         <TextBlock.Text>
             Path="Text" <Binding ElementName="tb" />
         </ TextBlock.Text>
     </ TextBlock>
     <Grid.RowDefinitions>
         <RowDefinition />
         <RowDefinition />
     </ Grid.RowDefinitions>
     X:Name="tb" <textbox Grid.Row="1" /> <! - This is a second content set, invalid in v4 ->
 </ Grid>
xmlns inferred property element

Silverlight 3 supports XAML with elements that do not specify property information XAML namespace of its primary object element. April Silverlight does not support this and throws an analysis of XAML. For example, the following XAML in Silverlight 3 is valid but it is not in Silverlight 4:
<Controls: WrapPanel Width = "100" Height = "100"

xmlns: controls = "clr-namespace: System.Windows.Controls; assembly = System.Windows.Controls">

<WrapPanel.Background> <! - Needs prefix ...-->

Color="Red" <SolidColorBrush />

</ WrapPanel.Background>

</ Controls: WrapPanel>
Xmlns attribute false

In some cases, 3 supports Silverlight XAML with xmlns attribute-that are not resolved. In such cases, Silverlight 3 uses an object element xmlns reserve. April Silverlight does not support this and throws an analysis of XAML.

Reply With Quote
  #2  
Old 08-08-2010
Member
 
Join Date: Feb 2008
Posts: 137
Re: XAML Processing Differences Between Silverlight 3 and Silverlight 4

Explicit object element to a collection of read-only collection

In Silverlight 3, the properties of a read-only collection may contain an object element for the type of collection. This violates the general principle that an object element creates an instance of type, it would not be valid for a collection of read-only. In this case, Silverlight 3 produces exception analysis. For example, the following code in Silverlight 3 is valid but it is not in Silverlight 4:

Code:
<DoubleAnimationUsingKeyFrames>
   <DoubleKeyFrameCollection>
     Value="100" <DiscreteDoubleKeyFrame KeyTime="0:0:2" />
     Value="400" <DiscreteDoubleKeyFrame KeyTime="0:0:4" />
   </ DoubleKeyFrameCollection>
 </ DoubleAnimationUsingKeyFrames>
Chain content content properties

Silverlight Version 3 supports the contents of a string object element only for a few objects, namely TextBlock and Run. Other objects do not support channels of content. For example, <button> Hello </ Button> not valid in Silverlight 3 and should have this format: Content="Hello" <Button />. In Silverlight 4, no such restriction is usually applied. However, should not be construed as any Silverlight control 4 can accept a string of content. The object model determines whether a particular control can accept a string of content or not, this being more important consideration than the consideration of whether it is possible to establish the corresponding property as a string of XAML content. Note that the text initialization string XAML seems content, but not a real chain establishing the XAML content property.

Control blanks

Silverlight 3 is whitespace in a more literal and more broadly, there are even some cases where CLRF is considered significant. Sometimes this led to a XAML file format with CRLF omitted to avoid unwanted whitespace in the presentation, but that was not legible in editing environments. Silverlight 4 uses a model of significant white space is more intuitive than similar to WPF. This model gets the blanks in the file format in most cases except in the case of certain containers with CLR attributes that deal with all the blanks as significant. This model gives blanks greater freedom to editing environments to enter spaces that improve the XAML format. Also, Silverlight 4 has text elements that allow even greater control of the problems associated with the presentation of the blanks.

Entities XAML

Silverlight 3 excludes non-existing entities in the namespace of the XAML ( x: ). In this case, Silverlight four exceptions occur if the analysis has no such entity as defined in XAML.

Scope of x: Key

Silverlight 3 only allows the use of x: Key in the field of ResourceDictionary. Silverlight also supports 4 x: Key element in any application where the type of support implements IDictionary.

Performance of x: Name / name fields XAML

XAML Object Elements than DependencyObject not support x: Name on the level of syntax Silverlight 3. However, Silverlight 4 accepts the syntax, but may not be able to add the object to XAML namespace.

Markup Extensions

Except for Binding , markup extensions in Silverlight 3 can only be used in the syntax of attributes, not the object element syntax. Except in the case of Binding , the constructor parameters of these extensions can not dial using the syntax of named parameters. For example, Akey StaticResource () works but StaticResource ResourceKey = () Akey does not work.

XAML Namespaces

Silverlight 3 obliges the subsequent limitations on the namespace declarations that differ from Silverlight XAML 4:
  • The root element must contain a declaration of default namespace. Not involve any implicit value.
  • Any declaration of default namespace (whether located in the root element or not) must be http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/client/2007 namespace or XPS (http://schemas.microsoft.com/xps/2005/06), which is used rarely.
  • The application manifest is technically Silverlight XAML, but its root is usually the subject Deployment , which generally must use the default XAML namespace xmlns = "http://schemas.microsoft.com/client/2007/deployment" for resolution.
  • Silverlight in April may also have similar restrictions, but these exist only in the behavior of compiling the XAML to build Page action not generally in the XAML parser that is used at runtime.
Reply With Quote
  #3  
Old 09-08-2010
Member
 
Join Date: Feb 2008
Posts: 137
Re: XAML Processing Differences Between Silverlight 3 and Silverlight 4

Performance of the compilation of marking or partial classes

When using x: Class, Silverlight 3 enables a behavior so that, if you set a property on the subclass of the root element, the property meets the property of the subclass but not exist in the root tag. Silverlight four exceptions occur in this case. The example below works on Silverlight 3 but an exception occurs in Silverlight in April.

Code:
public class MyPage: UserControl
 (
     public int Value (get; set;)
 )
Code:
 <UserControl x: Class = "SilverlightApplication1.MyPage" ...  Value = "17">
 </ UserControl>
In Silverlight 3 is accepted without error the mismatch between the type of the root tag in XAML and the type of class in the underlying code. 4 In Silverlight, the parser throws an exception.

Code:
namespace MyNS
 (
     public class Page: Canvas (etc.  etc.  )
 )

AND
 <UserControl x: Name = "parentCanvas" x: Class = "MyNS.Page" ...  />
Behavior analysis and search

In the following sections, analytical assessments and searched the support code that are managed differently in Silverlight 3 and Silverlight 4.

Duplicate sets of properties

In some cases, you can set the same property several times in the XAML for Silverlight 3 if it is a basic property is not only non-native implementation. April Silverlight does not allow it at all, and throws an analysis of XAML.

Evaluate enumeration values

When Silverlight 3 analyzes an enumeration with a text value initialization, generates an integer value. Silverlight in April, however, generates the enumeration value. This is important if you access the values in the underlying code, or enumerations are evaluated in the user interface. However, in general, the latter procedure is not recommended.

Check rates for the TypeConverter classes or Storyboard

Silverlight three visual states accept other than Storyboard, and classes with attributes TypeConverterAttribute than TypeConverter. In both cases, it is likely that problems in run time. However, it is accepted in the XAML markup for the compilation and loading. Silverlight four throws an exception in these cases.

Support of adjoining properties

XAML can be used attached properties with only a static setter. In Silverlight 4, these properties require a getter and a setter static static. Also, Silverlight 3 is a specific requirement: the adjoining properties must be implemented to support dependency properties. Silverlight 4 does not have this restriction.

Search StaticResource from the attributes of a link

Silverlight 3, an object subproperties Binding making a reference to an error StaticResource not produce any exception during parsing of XAML. The link subproperty acts as if that was not established. It is a typical behavior of StaticResource and may interfere with the purification of a link. Silverlight four throws an analysis for sub-properties of an object Binding which refer to StaticResource that generates an error.

System Primitives

The only compatible constructs a namespace System assigned, the combination of the assembly mscorlib in Silverlight ( which is normally assigned as sys: ) are sys: Double, sys: String, sys: Boolean and sys: Int32. (The intention here is to use the types "primitive" elements defined there as the object, usually for use as a resource in a resource dictionary).

Template Behavior
  • Silverlight 3 is allowed TemplateBinding link to a property that does not have a CLR accessor. Silverlight four blocks this behavior.
  • In Silverlight 3, templates can not be analyzable as resources. Silverlight four blocks this behavior.
  • The property names and TemplateBinding Setter.Property not case-sensitive in Silverlight 3, but are processed case-sensitive in Silverlight in April.
  • Silverlight 3 TemplateBinding a link or has not been addressed or is spelled incorrectly in an animation or storyboard is simply not set the property. 4 In Silverlight, there is an exception.
  • In Silverlight 3, if you create an object with a TargetType CONTROLTEMPLATES that targets a base class and used a link TemplateBinding a member of the subclass, TemplateBinding could solve that property as a behavior almost dynamic. Silverlight four treats it as a mistake for designers to detect and throws an exception. This happens in cases where there is no explicit TargetType, equivalent to TargetType = "Control."
  • Silverlight 3 is not an error loading a forward reference to a static resource defined elsewhere in a template. Silverlight four throws an exception in this case. Note that in this context, the behavior of Silverlight runtime 3 is undetermined. Silverlight four tries to detect this behavior in unpredictable execution time when generating templates. A template for Silverlight 3, which makes a forward reference to a static resource will continue to operate if it worked before, unless other factors change the duration and timing of implementation and, therefore, indeterminate behavior.

UserControl behavior
  • UserControl. Content is a protected property in Silverlight 3 but public property in Silverlight. As internal behavior of the parser, the XAML parser (and the compiler marking) of Silverlight 3 can set the property UserControl. Content of a control UserControl in XAML content, if you specify a value for x: Class.
Reply With Quote
Reply

  TechArena Community > ARENA > Guides & Tutorials
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "XAML Processing Differences Between Silverlight 3 and Silverlight 4"
Thread Thread Starter Forum Replies Last Post
Silverlight 5 released; will there be a Silverlight 6? GopuHD Windows Software 4 11-01-2012 02:28 PM
Silverlight 5 RC now Available Pa!trick Windows Software 3 29-09-2011 06:28 AM
While installing Silverlight I get "Silverlight is already installed" message Raja Ram Windows Software 5 28-04-2011 11:27 AM
How to install SilverLight 5 beta and SilverLight 4 on same Computer Mandarmalika Windows Software 3 17-04-2011 05:55 PM
What is SilverLight? Champak Windows Software 4 31-01-2009 10:21 AM


All times are GMT +5.5. The time now is 08:41 PM.