Reading and writing in .NET
| API | What it does |
|---|---|
System.Xaml.XamlXmlReader, XamlXmlWriter | read XAML text as a stream of nodes (StartObject, StartMember, Value, GetObject, NamespaceDeclaration, EndMember, EndObject), and write such a stream as text |
XamlObjectWriter, XamlObjectReader | build objects from a node stream, and make a node stream from an object graph |
XamlServices.Load, Parse, Save, Transform | the one-call forms: text to object, object to text |
XamlSchemaContext, XamlType, XamlMember | the type system the readers use to resolve names; a schema context can be customised to restrict or redirect types |
System.Windows.Markup.XamlReader.Load, XamlWriter.Save | WPF’s loaders for loose files; XamlWriter.Save has limits (it does not write bindings or resource references as written) |
Windows.UI.Xaml.Markup.XamlReader.Load(string) (UWP), Microsoft.UI.Xaml.Markup.XamlReader.Load (WinUI) | build an element tree from a string |
XamlBinaryWriter, XamlBinaryReader (internal, WPF) | produce and read BAML |
Editors and designers
- Visual Studio – the XAML editor with IntelliSense for types, properties, bindings (with the data type from
d:DataContext), a designer surface for WPF, UWP, WinUI and MAUI, and XAML Hot Reload that applies edits to the running application. - Blend for Visual Studio – a visual designer for states, templates and animations; it writes the
d:andmc:attributes. - JetBrains Rider and ReSharper – XAML editing, previewer and refactoring for WPF, MAUI and Avalonia.
- Avalonia previewer – a live preview in Visual Studio, Rider and Visual Studio Code, with
Design.PreviewWith,Design.DataContextandDesign.Width/Heightattributes (the Avalonia counterparts ofd:). - Visual Studio Code – XAML extensions for syntax and formatting; C# Dev Kit for MAUI; the Avalonia extension.
- XamlPad – the small editor of the Windows SDK that showed a XAML page as it was typed; no longer shipped.
Format, check and decompile
- XAML Styler – a Visual Studio extension and command-line tool that sorts attributes and indents XAML by a settings file.
- ILSpy – shows the BAML resources of a WPF assembly as XAML.
- The compiler itself –
msbuildwith theMarkupCompilePass1andMarkupCompilePass2targets (WPF),XamlCompiler.exe(UWP, WinUI), the MAUI XamlC and the Avalonia compiler report XAML errors with line and column. - This site’s viewer – shows the outline, markup extensions, namespaces, names, resources, events and problems of a file in the browser, without the assemblies and without drawing the UI (see the overview).
What is installed on this Mac
No .NET SDK, WPF, MAUI or Avalonia is installed, so no tool above was run. Real .xaml files from open-source WPF, UWP and Windows Phone projects and from the property page rules of MSBuild SDKs were used to test the viewer.
Not described
Known, not yet covered
- Reference: command-line options of the compilers and previewers are not listed.
Unknown
- Reference: whether the third-party tools named here (XAML Styler, extensions for Visual Studio Code) are current was not checked.