Tag Archives: wpf

Worked Example: Programmatic Addition of a WPF Data Template to a Resource Dictionary

I have noticed some interest in my earlier post on how to add a WPF data template to a resource dictionary in code and so this post is a demonstration of the technique.  The code is presented in F# but I have deliberately kept the code simple and fairly non-functional so that those of a C# or VB.NET background can follow the process easily.

Continue reading


Chaining Side Effects in F# (and WPF DependencyProperty as a Special Case)

The first question that any functional programmer should ask is, “why are there side effects?!” Side effects are anathema to functional programming purists because they introduce many kinds of undesirable characteristics into code, limiting optimisation and restructuring options. However, most object-oriented libraries, including the .NET BCL, depend on side effects and many of these are intrinsic to writing .NET applications.

WPF is a special case where this applies, with DependencyProperty fields.

Continue reading

Creating WPF Dependency Properties in F#

This is a quick post demonstrating how to create WPF Dependency Properties in F#. There is a bit of a trick to it as you have to use the val keyword to define a field and that field must be mutable and you also have to use explicit interface access.

Continue reading

Viewing Default WPF Control Templates (free tool)

For those of you that do not have Microsoft Expression Blend (or an equivalent), using XAMLPad and Visual Studio can be okay. However, if you want to create custom controls that are similar to existing (standard or third party) controls then it can be tricky to find out how best to do it. This little utility uses the XamlWriter class to export a default template from a WPF control.

Continue reading