1 / 48

XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools

CL24. XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools. Michael.Shim@microsoft.com Program Manager, http://michaelshim.com/blog Rob.Relyea@microsoft.com Architect, http://robrelyea.com/blog . XAML Status & Futures. XAML @ 3 year mark We’ll focus on 5 areas today

shayla
Download Presentation

XAML Futures for Microsoft .NET, Microsoft Silverlight and Tools

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CL24 XAML Futuresfor Microsoft .NET,Microsoft Silverlight and Tools Michael.Shim@microsoft.com Program Manager, http://michaelshim.com/blog Rob.Relyea@microsoft.com Architect, http://robrelyea.com/blog

  2. XAML Status & Futures • XAML @ 3 year mark • We’ll focus on 5 areas today • Runtime Parsing • Static Analysis • Compile Time • Design Time • Localization Static Analysis Design Time Compile Time Runtime Localization

  3. XAML Runtimes

  4. 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

  5. XAML for UI or Non-UI • 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 PF.dll WF, WCF,More… WPF PresentationFramework.dll (PF.dll) Workflow BAMLengine XAML engine BAML engine XOML engine PC.dll PresentationCore.dll (PC.dll) XomlTypeInfo WindowsBase.dll WindowsBase.dll System.Xaml.dll XamlTypeInfo XAML engine XamlTypeInfo Mscorlib, System, System.Xml Mscorlib, System, System.Xml 4 3.x

  6. XAML Data Model: O-M-V + Types O-M-V • Root Object • Objects have Members • Members contain Objects and/or Values • Some Objects are Collections • Collections have a property to hold their Items Types • Objects are instances of XamlTypes • Members are instances of XamlMembers Object Member Value

  7. XAML Node Stream StartObject StartMember Canvas Children StartObject StartMember Value Button “Green” Background StartMember Value “OK” Content StartObject StartMember Value “Cancel” Content Button

  8. Working 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.

  9. Adding Script to XAML demo

  10. More 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

  11. IXamlTypeResolver, IAmbientProvider, IXamlSchemaContextProvider 1 • <StyleTargetType="Button" > • <SetterProperty="Background" • Value="Red" /> • </Style> 2 3 1) Typetype = xamlTypeResolver.Resolve("Button"); 2) Value of Style.TargetType determined by calling IAmbientProviderto 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(…);

  12. IRootObjectProvider, IXamlNameResolver 1 • <Button Click=“foo” /> • <Button Click=“{l:EventWire foo}” /> • <Button Height=“{l:GetValue tb1.Height}” /> 2 3 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).

  13. More 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 1 2 3 4 5 6

  14. XAML 2009 EnhancementsRecap 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.

  15. 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

  16. Silverlight XAML Improvement Plan Starts working: Invalid XAML stops working: Duplicate property setting … • Text as content <Button>Hello</Button> • All MarkupExtensions work in ObjectElement syntax • Better debuggability • Better error messages and locations • Throws on invalid XAML earlier • … Will have tools to help improve the validity of your XAML.

  17. Silverlight 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

  18. XAML Static Analysis

  19. XAML 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

  20. Microsoft XAML Toolkit announcing Provides Static Analysis, Localization, & XamlDom for .NET/Silverlight XAML

  21. XamlDom • Represents the XAML Node stream in a tree • XML nodes • (XmlReader-> XDocument) • XAML nodes (S.X.XamlReader -> XamlDom) StartObject StartMember Canvas Children StartObject StartMember Value Button “Green” Background StartMember Value “OK” Content StartObject StartMember Value “Cancel” Content Button Background “Green” Button “OK” Content Canvas Children Button “Cancel” Content

  22. XamlDom • Like XLinq for XDocument, can use Linq against XamlDom • XamlDom useful for Tools • XAML Designers (Blend/VS) • Static Analysis • Transformations (Converters)

  23. Querying the XamlDom demo

  24. XamlDom Functional Construction <ButtonBackground="Red">Click Me!</Button> XamlXmlWriterxamlXmlWriter = newXamlXmlWriter("myfile.xaml", schemaContext); XamlTypebuttonType = schemaContext.GetXamlType(typeof(Button)); XamlMemberbackgroundMember = buttonType.GetMember("Background"); XamlMembercontentMember = 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(); newXamlDomObject(typeof(Button), schemaContext, newXamlDomMember("Background", "Red"), newXamlDomMember("Content", "Click Me!") ); XamlDomServices.Save(domObject, "myfile.xaml");

  25. Tooling 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

  26. XAML FxCop demo

  27. BaseXamlRule • publicabstractclassBaseXamlRule: BaseIntrospectionRule • { • publicabstractvoidCheckXaml(XamlDomObjectrootObjectNode, • XamlSchemaContextschemaContext, • stringresourceName); • }

  28. XAML FxCop • Processes all XAML/BAML files in a Resource and calls CheckXaml • CTP supports WPF, Silverlight, and Workflow • Considering a visitor pattern as well

  29. UISchemaContext • XamlSchemaContextthat 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

  30. FxCop 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

  31. 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

  32. WPF/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

  33. XAML Designers • VS2010/Blend: Integration with designers and runtime parsers • WPF Data/Control Template editing is significantly faster • Visual Studio 2010 • Added MarkupExtensionintellisense • 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

  34. XAML Localization

  35. Approaches to XAML UI Localization x:Uid {MarkupExtension} {Binding} {StaticResource} to resources in ResourceDictionaries {x:Static} to strongly typed ResX resources {my:Loc} • LocBaml

  36. x:Uid vs {MarkupExtension} (1 of 2) x:Uid <Button Click=“handleOk” x:Uid=“button1”> Ok </Button> {MarkupExtension} <Button Click=“handleOk” Content=“{SomeMEcontentValue}” />

  37. x:Uid vs {MarkupExtension} (2 of 2)

  38. XAML Localization Status • Silverlight • Build: None • Runtime: {Binding} • PostBuild: None • .NET • Build: None • Runtime: {Binding}, {SR}, {my:Loc} • PostBuild: LocBaml, 3rd Parties

  39. XAML 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

  40. Prototype of BuildTimeLocalization of a Silverlight Application demo

  41. Pain points • Internal and External Pain Points • Assembly dependency • File format (.csv) • Tools support • Visual designer • BamlWriter • Metadata + overriding • Uid generation • Fallback

  42. Plans 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

  43. 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

  44. YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation forms online at MicrosoftPDC.com

  45. 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/learn Built by Developers for Developers….

  46. Discussion • Nowand in Web lounge • Engage on blogs, XAML Toolkit forum

More Related