This project is read-only.

Xaml Code Generator

.Net 4 introduces Xaml Services that can load Xaml Object Trees and it provides great deal in terms of intellisense and code behind facilities, however this can only be used where Xaml Services are installed. Also it is quite painful to debug and hide the generated baml resources, that actually is quite easy to disassemble and view the source.

Xaml Code Generator can easily solve these problems by creating source code equivalent to loading object via Xaml Services. Instead, once generated, the performance of source code is quite faster then baml and xaml. Since ASP.NET and WinForms, code behind files did serve great support to link the UI and Code. However in WPF and Silverlight does not support simple references to code behind objects except events. There are work arounds, but we decided to create Xaml Code Generator that will solve lot of problems.

Benefits to WPF and Silverlight

  1. Xaml pages can now use x:Reference markup extension
  2. Xaml pages can support generic type parameters
  3. Xaml page can now derive from any control/panel
  4. Xaml can easily reference any expression that involves code behind operation including "this" keyword
  5. By using custom Xaml markup extensions, you can reuse Xaml between WPF and Silverlight

Known limitations with Xaml Code Generated files

  1. Control Templates and Styles must use respective WPF/Silverlight markup only
  2. No code behind files can be generated for Control Templates and Styles
  3. Xaml pages can not be used with Navigation Urls
  4. Instead code generated files are simply source code equivalent of Xaml, and they should be treated as .Net CLR Objects instead of Xaml Pages and there exists no equivalent baml resources

So how to use benefits of Code Generator as well as XAML

We recommend following pattern to make use of best of both the worlds
  1. Create Main Application Window/Page as regular Xaml
  2. Instead of User Controls, use Xaml derived from Equivalent controls, such as StackPanel, Grid etc, and use them in Main Window/Pages
  3. In this pattern, generated CLR objects of xaml will perform exactly same

Last edited Sep 22, 2010 at 10:49 AM by neurospeech, version 1


No comments yet.