xaml futures for microsoft .net, microsoft silverlight and tools
DESCRIPTION
CL24. XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools. [email protected] Program Manager, http://michaelshim.com/blog [email protected] Architect, http://robrelyea.com/blog . XAML Status & Futures. XAML @ 3 year mark We’ll focus on 5 areas today - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/1.jpg)
XAML Futuresfor Microsoft .NET,Microsoft Silverlight and [email protected] Manager, http://michaelshim.com/blog
[email protected], http://robrelyea.com/blog
CL24
![Page 2: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/2.jpg)
XAML Status & Futures> XAML @ 3 year mark> We’ll focus on 5 areas today
> Runtime Parsing> Static Analysis> Compile Time> Design Time> Localization
Design Time
Compile Time Runtime
Static Analysis
Localization
![Page 3: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/3.jpg)
XAML Runtimes
![Page 4: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/4.jpg)
Runtime Improvements (Parsers)> .NET 4 using System.Xaml.dll
> Ready for UI and non-UI> More services available to
MarkupExtensions & TypeConverters> XAML2009 Language Features
> Silverlight XAML Futures> Status> Improvements> Direction
![Page 5: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/5.jpg)
> XAML ready types or frameworks only need: mscorlib, System, System.Xml, System.Xaml
> Removing the XAML engine out of Fx Libraries> XamlReader.Load still in PF.dll
XAML for UI or Non-UI
WF, WCF,
More…
PresentationCore.dll (PC.dll)
PresentationFramework.dll (PF.dll)
XAML engine
3.x
WindowsBase.dll
XamlTypeInfo
Mscorlib, System, System.Xml
BAMLengine
PC.dll
PF.dll
WindowsBase.dll
BAML engine
4
System.Xaml.dll
XamlTypeInfo
XAML engine
Mscorlib, System, System.Xml
WPFWorkflo
w
XOML engin
e
Xoml
TypeInfo
![Page 6: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/6.jpg)
XAML Data Model: O-M-V + TypesO-M-V> Root Object> Objects have Members> Members contain Objects and/or Values> Some Objects are Collections> Collections have a property
to hold their ItemsTypes> Objects are instances of XamlTypes> Members are instances of XamlMembers
Object Member Value
![Page 7: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/7.jpg)
XAML Node Stream
StartObject
Value
StartMember
StartObject StartMember
ValueStartMember
ValueStartObject StartMember
Background
ChildrenCanvas
Button
Button
Content
Content
“Green”
“OK”
“Cancel”
![Page 8: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/8.jpg)
>>FUTUREWorking with XAML Node Streams
Enables:> Scenario: XamlPad that strips event
handlers> Scenario: Adding Script to XAML
> Note: a technology demo, not best practice for most applications.
![Page 9: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/9.jpg)
Adding Script to XAML
demo
![Page 10: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/10.jpg)
>>FUTUREMore Power for MarkupExtensions
and TypeConverters> V3 MEs and TCs
> IXamlTypeResolver, IUriContext & IProvideValueTarget
> V4 MEs and TCs> IRootObjectProvider> IXamlNameResolver & IXamlNameProvider
(Save)> IAmbientProvider> IDestinationTypeProvider> IXamlNamespaceProvider &
INamespacePrefixLookup (Save)> IXamlSchemaContextProvider> IXamlObjectWriterFactory
![Page 11: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/11.jpg)
IXamlTypeResolver, IAmbientProvider, IXamlSchemaContextProvider<Style TargetType="Button" > <Setter Property="Background" Value="Red" /> </Style>
3
12
1) Type type = xamlTypeResolver.Resolve("Button"); 2) Value of Style.TargetType determined by calling IAmbientProvider to find instances of Style.TargetType up the parse stack. 3)xamlSchemaContext = ixscp.SchemaContext;xamlType = xamlSchemaContext.GetXamlType(typeof(Button));xamlMember = xamlType.GetMember("Background");value=xamlMember.TypeConverter.ConverterInstance.ConvertFrom(…);
![Page 12: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/12.jpg)
IRootObjectProvider, IXamlNameResolver<Button Click=“foo” /><Button Click=“{l:EventWire foo}” /><Button Height=“{l:GetValue tb1.Height}” />
3
12
1) Parser looks for foo method on Root object.2) IRootObjectProvider can get root object.3) IXamlNameResolver can find element with Name of tb1 (even it is hasn’t been parsed yet).
![Page 13: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/13.jpg)
>>FUTUREMore Power for MarkupExtensions
and TypeConverters> V3 MEs and TCs
> IXamlTypeResolver, IUriContext & IProvideValueTarget
> V4 MEs and TCs> IRootObjectProvider> IXamlNameResolver & IXamlNameProvider
(Save)> IAmbientProvider> IDestinationTypeProvider> IXamlNamespaceProvider &
INamespacePrefixLookup (Save)> IXamlSchemaContextProvider> IXamlObjectWriterFactory
3
1 2
45
6
![Page 14: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/14.jpg)
XAML 2009 Enhancements Recap from PDC08> Improved named references (x:Reference)> Full generics support (x:TypeArguments)> Built-in types (x:String, etc…)> Support arbitrary dictionary key types
(x:Key)> Support events without compilation> Define new properties (x:Members,
x:Property)> Use non-default constructors
(x:Arguments)> Use factory methods (x:FactoryMethod)Note: Compilers + Designers in .NET 4, VS2010, &
Blend won’t have XAML2009 support at RTM.
![Page 15: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/15.jpg)
Runtime Parser Improvements> .NET 4 using System.Xaml.dll
> Ready for UI and non-UI> More services available to
MarkupExtensions, TypeConverters> XAML2009 Language Features
> Silverlight XAML Futures> Status> Improvements> Direction
![Page 16: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/16.jpg)
>>FUTURESilverlight XAML Improvement Plan
Starts working:> Text as content
<Button>Hello</Button>> All MarkupExtensions
work in ObjectElement syntax
> Better debuggability> Better error messages and
locations> Throws on invalid XAML
earlier> …
Invalid XAML stops working:
> Duplicate property setting> …
Will have tools to help improve the validity of your XAML.
![Page 17: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/17.jpg)
>>FUTURESilverlight XAML Direction
> In the future, moving the Silverlight XAML parser to the same XAML Node infrastructure
> Better compatibility with .NET XAML and ability to evolve quickly
> Scenarios will drive future addition of > More XAML2006 features> XAML2009 features
![Page 18: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/18.jpg)
XAML Static Analysis
![Page 19: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/19.jpg)
>>FUTUREXAML Static Analysis
> Declarative UI provides great opportunities for analysis, however, we don’t support FxCop on XAML today.
> We are going to make it easy> XamlDom> FxCop & XAML
> WPF & Silverlight integration
![Page 20: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/20.jpg)
Microsoft XAML Toolkit
Provides Static Analysis, Localization, & XamlDom for .NET/Silverlight XAML
announcing
![Page 21: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/21.jpg)
>>FUTUREXamlDom Represents the XAML
Node stream in a tree• XML nodes (XmlReader ->XDocument)• XAML nodes
(S.X.XamlReader -> XamlDom)
StartObject
Value
StartMember
StartObject StartMember
ValueStartMember
ValueStartObject StartMember
Background
ChildrenCanvas
Button
Button
Content
Content
“Green”
“OK”
“Cancel”
XDObject XDMember
XDObject
XDMember Value
XDMember Value
XDObject XDMember Value
Canvas Children
Button
Button
Background
“Green”
Content “OK”
Content
“Cancel”
![Page 22: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/22.jpg)
>>FUTUREXamlDom
> Like XLinq for XDocument, can use Linq against XamlDom
> XamlDom useful for Tools> XAML Designers (Blend/VS)> Static Analysis> Transformations (Converters)
![Page 23: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/23.jpg)
Querying the XamlDom
demo
![Page 24: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/24.jpg)
XamlDom Functional Construction
new XamlDomObject(typeof(Button), schemaContext, new XamlDomMember("Background", "Red"), new XamlDomMember("Content", "Click Me!"));XamlDomServices.Save(domObject, "myfile.xaml");
XamlXmlWriter xamlXmlWriter = new XamlXmlWriter("myfile.xaml", schemaContext);XamlType buttonType = schemaContext.GetXamlType(typeof(Button));XamlMember backgroundMember = buttonType.GetMember("Background");XamlMember contentMember = buttonType.GetMember("Content");xamlXmlWriter.WriteStartObject(buttonType);xamlXmlWriter.WriteStartMember(backgroundMember);xamlXmlWriter.WriteValue("Red");xamlXmlWriter.WriteEndMember();xamlXmlWriter.WriteStartMember(contentMember);xamlXmlWriter.WriteValue("Click Me!");xamlXmlWriter.WriteEndMember();xamlXmlWriter.WriteEndObject();xamlXmlWriter.Close();
<Button Background="Red">Click Me!</Button>
![Page 25: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/25.jpg)
>>FUTURETooling Silverlight XAML
> .NET & Silverlight metadata are different> ContentPropertyAttribute is in two
different assemblies (System.Xaml.dll vs System.Windows.dll)
> Silverlight > Some markup extensions don’t have CLR
types> Some types are missing metadata (like
TypeConverterAttribute)> System.Xaml.dll needs a Silverlight
XamlSchemaContext> Tools can rely on the
SilverlightSchemaContext
![Page 26: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/26.jpg)
XAML FxCop
demo
![Page 27: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/27.jpg)
BaseXamlRule
public abstract class BaseXamlRule : BaseIntrospectionRule{ public abstract void CheckXaml(XamlDomObject rootObjectNode,
XamlSchemaContext schemaContext,
string resourceName);}
![Page 28: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/28.jpg)
>>FUTUREXAML FxCop
• Processes all XAML/BAML files in a Resource and calls CheckXaml
• CTP supports WPF, Silverlight, and Workflow
• Considering a visitor pattern as well
![Page 29: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/29.jpg)
>>FUTUREUISchemaContext
> XamlSchemaContext that works with both WPF & Silverlight> Translates types between both worlds> Write one FxCop rule against WPF or
Silverlight, works against both platforms> Only useful for static analysis
![Page 30: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/30.jpg)
>>FUTUREFxCop Details
> Working with FxCop team on better integration (resource granularity, suppressions, etc…)
> CTP includes following FxCop support:> BaseXamlRule> Rules to improve Silverlight content> XAML validation rule> UISchemaContext
![Page 31: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/31.jpg)
XAML Compilers> WPF 4
> Fixed some impactful bugs> Out of memory, incremental build issues,
CompilerGenerated attributes for FxCop> Visual Studio/MSBuild support multi-targeting> Couldn’t afford to support XAML2009 in compiler &
BAML> WPF 3.x Compiler Update
> Port fixes to 3.x XAML compiler coming early next year
> Silverlight 4> Minor bug fixes
> Workflow 4> New XAML compiler
![Page 32: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/32.jpg)
>>FUTUREWPF/Silverlight Compiler Futures
> Improved compilers on horizon for both
> Goals> Based on System.Xaml Node stream> Better validation
> Additional XAML Validation component that can be used elsewhere (FxCop, Designers, localization, etc…)
> Improve generated files (.g.cs/.g.vb) (XmlnsDefinitionAttribute, RuntimeNameProperty, etc…)> x:Property
> Add XAML2009 support for WPF
![Page 33: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/33.jpg)
XAML Designers> VS2010/Blend: Integration with designers and
runtime parsers> WPF Data/Control Template editing is significantly
faster> Visual Studio 2010
> Added MarkupExtension intellisense> Supports SL & WPF XAML> Better performance for intellisense> Fixed bugs in parser
> Blend> Added intellisense in XAML view> Better incremental parse/update> Better support for attached properties> Fixed bugs in parser
![Page 34: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/34.jpg)
XAML Localization
![Page 35: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/35.jpg)
Approaches to XAML UI Localizationx:Uid> LocBaml
{MarkupExtension}> {Binding}> {StaticResource} to
resources in ResourceDictionaries
> {x:Static} to strongly typed ResX resources
> {my:Loc}
![Page 36: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/36.jpg)
x:Uid vs {MarkupExtension} (1 of 2)x:Uid<Button Click=“handleOk” x:Uid=“button1”> Ok</Button>
{MarkupExtension}<Button Click=“handleOk” Content=“{SomeME contentValue}” />
![Page 37: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/37.jpg)
x:Uid vs {MarkupExtension} (2 of 2)Criteria x:Uid {ME}
Impact on XAML Better PoorCider/Blend Value Editing Experience
Better Poor
Runtime Performance Better Ok(lite + heavy)
Post-Build Localization enabled
Yes No
Injection of Values No* -> Yes
No
Support for RichText Yes NoSupport for Element Reordering
Yes No
![Page 38: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/38.jpg)
XAML Localization Status> Silverlight
> Build: None> Runtime: {Binding}> PostBuild: None
> .NET> Build: None> Runtime: {Binding}, {SR}, {my:Loc}> PostBuild: LocBaml, 3rd Parties
![Page 39: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/39.jpg)
>>FUTUREXAML Localization Plan
> Silverlight> Build: Support x:Uid based localization> Runtime: {Binding}> PostBuild: Support x:Uid based
localization> .NET
> Build: Support x:Uid based localization> Runtime: {Binding}, {SR}, {my:Loc}> PostBuild: Improve Pain Points
![Page 40: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/40.jpg)
Prototype of BuildTime Localization of a Silverlight Application
demo
![Page 41: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/41.jpg)
>>FUTUREPain points
> Internal and External Pain Points> Assembly dependency> File format (.csv)> Tools support> Visual designer> BamlWriter> Metadata + overriding> Uid generation> Fallback
![Page 42: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/42.jpg)
>>FUTUREPlans for XAML Localization
> Focus very soon on this area for WPF & Silverlight
> Engage with community for feedback> Deliver Microsoft.Xaml.Localization.dll
as part of a future XAML Toolkit CTP
![Page 43: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/43.jpg)
Call for Action> Begin using .NET 4 Beta 2 &
System.Xaml.dll> Download Microsoft XAML Toolkit CTP
for Static Analysis and XamlDom> http://code.msdn.microsoft.com/XAML> Write tools for .NET/Silverlight XAML> Write FxCop rules> Give feedback on XamlDom
> Give feedback to improve XAML development
![Page 44: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/44.jpg)
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation
forms online atMicrosoftPDC.com
![Page 45: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/45.jpg)
Learn More On Channel 9> Expand your PDC experience through
Channel 9
> Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses
channel9.msdn.com/learnBuilt by Developers for Developers….
![Page 46: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/46.jpg)
Discussion> Now and in Web lounge> Engage on blogs, XAML Toolkit forum
![Page 47: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/47.jpg)
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
![Page 48: XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools](https://reader035.vdocument.in/reader035/viewer/2022062501/568160c2550346895dcfebae/html5/thumbnails/48.jpg)