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.

Would be even nicer if they had expression overloads for stuff like BindContent. Then you could write BindConten(b => b.Text)

Daniel

http://realfiction.net Frank Quednau

Hello Daniel,
as creator of this still quite pre 1.0 package, I would like to chime in: You can write BindContent(“Text”), the darned thing about using dynamic in this context is that the whole lambda resolution business is done by the compiler. Inference of delegate type for lambdas breaks down in the dynamic scenario, so you have to specify the type of your lambda expression yourself, which is why the property of the DataContext to be bound is specified as a string.

For this the project has some helpers that set the correct type for some operations, but by thinking about your suggestion a new helper should be possible that will allow you to do this:
// This op sets bind to a fixed, known type;
var bind = X.ContextBinder();
// bind is some func type whose return is understood by DynamicXaml
_builder.Start().BindContent(bind(x => x.Text));

I will see if I can implement it in the near future.

Looking for Help or Training?

The following are companies owned by bloggers who contribute to ElegantCode.com, or those who are freelancers.