Rendering Project Data to XAML

Overview

XAML (Extensible Application Markup Language) is a declarative XML-based language used primarily for defining user interfaces in .NET-based technologies like WPF and UWP. Aspose.Tasks for .NET allows developers to export Microsoft Project data (MPP, XML) to XAML format, which can then be embedded in desktop applications, printed, or further customized using WPF/XAML toolkits.

This feature is useful when:

Supported Output Views

The PresentationFormat enumeration defines supported view types when exporting to XAML:

These can be combined with display options to fully customize output.

Rendering to XAML with Save Options

To render a project file to XAML:

  1. Create an instance of XamlOptions;
  2. Configure layout, view, and display settings:
    • FitContent: ensures the content fits into view;
    • LegendOnEachPage: toggles legend visibility;
    • Timescale: sets granularity (e.g., Days, Weeks);
    • View: defines the layout and columns to include;
  3. Save the project using Project.Save() with SaveFileFormat.XAML.

Example 1: Basic Save to XAML

1Project project = new Project("New Project.mpp");
2project.Save("RenderToXAML_out.xaml", SaveFileFormat.XAML);

Advanced Usage: Customizing View Options

Aspose.Tasks allows fine-grained customization of the XAML output. You can define:

Example 2: Export XAML with View Options

1Project project = new Project("New Project.mpp");
2SaveOptions options = new XamlOptions();
3options.FitContent = true;
4options.LegendOnEachPage = false;
5options.Timescale = Timescale.ThirdsOfMonths;
6project.Save("RenderXAMLWithOptions_out.xaml", options);

Rendering with Different Presentation Formats

You can choose different data perspectives when exporting to XAML using the PresentationFormat property.

Example 3: Export TaskUsage, ResourceUsage, and Gantt views

1Project project = new Project("New Project.mpp");
2SaveOptions options = new XamlOptions();
3options.PresentationFormat = PresentationFormat.GanttChart;
4project.Save("RenderDifferentPresentationFormatsToXAML_out.xaml", options);

Summary

Exporting project data to XAML using Aspose.Tasks for .NET opens up powerful integration capabilities with WPF/XAML-based desktop applications. The output is vector-based, resolution-independent, and ready to be styled and displayed dynamically.

🔗 See also:

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.