プロジェクトデータをXAMLにレンダリングします
概要
XAML(拡張可能なアプリケーションマークアップ言語)は、主にWPFやUWPなどの.NETベースのテクノロジーのユーザーインターフェイスを定義するために使用される宣言的なXMLベースの言語です。 .NETのAspose.Tasksを使用すると、開発者はMicrosoftプロジェクトデータ(MPP、XML)をXAML形式にエクスポートできます。これは、デスクトップアプリケーション、印刷、またはWPF/XAMLツールキットを使用してさらにカスタマイズできます。
この機能は、次の場合に役立ちます
- WPFを使用してリッチUIにプロジェクトデータを表示します。
- デスクトップシステムに読み取り専用ガントビューを埋め込むことを計画しています。
- プラットフォーム中立高忠実度でプロジェクトビューをレンダリングするには、**ベクトル出力が必要です。
サポートされている出力ビュー
PresentionFormat列挙は、XAMLにエクスポートするときにサポートされているビュータイプを定義します。
- 「Ganttchart」 - タスクとそのタイムラインを表示します。
- 「TaskUsage」 - タスクごとの課題と作業を提示します。
- 「ResourceUsage」 - リソースごとのワークロード分布の詳細。
resourcesheet- リソースの表形式のビュー。
これらをディスプレイオプションと組み合わせて、出力を完全にカスタマイズすることができます。
保存オプションでXAMLにレンダリングします
プロジェクトファイルをXAMLにレンダリングするには:
- 「xamloptions」のインスタンスを作成します。
- レイアウト、表示、表示設定を構成します。
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;
project.save()を使用してプロジェクトを保存しますsavefileformat.xaml。
例1: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:
- Which columns are shown using
GanttChartColumn; - What font, text alignment, or column widths to apply;
- Whether to include non-working time or roll-up tasks.
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: