Getting started - Athari/Alba.Jaml Wiki
!!!WARNING!!! This library is a proof-of-concept and as such not intended to be used in real projects. You're welcome to experiment, but please don't fret if something doesn't work.
Alba.Jamlproject to your solution.
Json.NETreference (you can use Json.NET NuGet package).
- To automatically regenerate XAML file when JAML file is changed, install T4 Toolbox.
- To get some syntax highlighting in Visual Studio, open Tools > Options > Text Editor > File Extension, enter
jamlinto Extension field, choose Script Editor in Editor drop-down, and click Apply.
Jaml.ttincludein your project with the following code (you may need to change paths to assemblies):
<#@ template hostspecific="true" debug="true" #><#@ output extension="g.xaml" #><#@ assembly name="$(SolutionDir)\Alba.Jaml\bin\Debug\Newtonsoft.Json.dll" #><#@ assembly name="$(SolutionDir)\Alba.Jaml\bin\Debug\Alba.Jaml.dll" #><#@ include file="$(SolutionDir)\Alba.Jaml\T4\Jaml.ttinclude" #>
- Create a new text file with
jamlextension, its name will become class name. You can use code from [[Example 1: Simple window]] as a strating point.
Custom Tooloption on the
Propertiespage of the JAML file to
T4ScriptFileGenerator. A new TT sub-file will be created. Replace its contents with the following code (you may need to change path to
Jaml.ttincludeif it's not in the same directory as JAML file):
<#@ include file="Jaml.ttinclude" #><# GenerateJaml(); #>
- Three new sub-files will be created:
[FileName].g.xaml- generated XAML, will be regenerated when JAML is saved
[FileName].g.xaml.cs- generated CS with converters, will be regenerated when JAML is saved
[FileName].xaml.cs- user code-behind
Now you can write code in your JAML file. When you need to create new JAML files, you need to repeat only steps 7 and 8.