Developing on Staxmanade

NuGet Project Uncovered: DynamicXaml

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

DynamicXaml takes a fluent approach to building up xaml in code. Following the pattern laid down by the HtmlTags project, this project provides a very clean way to write out your xaml code in C#.

I’ve copied a sample from the github readme below.

var _builder = new XamBuilder();
var button =
_builder.Start<Button>()
.Margin("5,0")
.WidthAndHeight(200d,30d)
.Create();



One of the things I like about these projects is if you can’t use markup and are pushed to write your xaml in C#, you can apply some great tricks to reduce duplication with your code. (Not sure how this library works out, but I would suspect that if you created a default Button object, it would allow you to override specific properties one at a time or extend with new properties. This way you can create your base controls and only tweak as necessary.