*Update: Custom WPF Controls in F# is now available on Codeplex at http://wpffsharp.codeplex.com. You can still download the source from my site here. (Works best withVSTS2010 Beta1)
Screen Shot
It is a translation of SAMS WPF Control Development Unleashed: Building Advanced User Interfaces written by Pavan Podila, and Kevin Hoffman to F#. I picked this book for translation as it covers many advanced topics that other books shy away from. I have been a reader of Pavan Podila’s blog Pixel in Gene for some time, and I have also been waiting for a book dedicated advanced UIs, so when I heard that he was coming out with such a book I knew it was going to be exactly what I needed.
WPF Control Development
The aim behind this project is to serve as an extensive collection non trivial examples of WPF/F# UI. As I introduce people to F#, one thing I am constantly asked is; can it do GUI. Now I can say yes, … well sort of. So far I have only translated 3,500 lines of F# code, and I am still not finished.
I’m doing this primarily as a learning experience and as a forcing function. I have already learned a lot about WPF and F#, and I plan on continuously improving the code as I learn more. Other contributions to the project would be very welcome, and if you spot mistakes or know of any better implementations please don’t hesitate to let me know.
I hope that you find this code to be useful to your WPF and F# projects , and happy coding.
-Matt
Read on for a list of known bugs;
A recent upgrade from VSTS 2010 Beta 1 to VSTS 2010 Beta 2 has unfortunately caused a whole lot of new bugs (on top of the ones that were already there).
List of known bugs:
Chapter 18 – ComputedStartOffsetProperty on type RangeSelector
- Chapter 2 – Media element doesn’t play
- Chapter 9 - TransitionContainer (delegate blocked off from TransitionTester_Loaded)
- Chapter 10 – ComponentResourceKey ?? Not sure what is happening here
- Chapter 10 – Custom Chrome Window, no skin on window
- Chapter 11 – GardenViewPanel3D and Interactive GardenViewPanel3D both register the same names (they work individually)
- Chapter 12 – Issues with enums for 3D mesh
- Chapter 13 – Dependency properties for SqueezeEffect and DisplacementEffect overlap? “Input’ property was already registered by ‘DisplacementEffect’”
- Chapter 14 – WeekEvent / Command Source (Property SpikeControl.Command not found)
- Chapter 15 – Media element doesn’t play
- Chapter 17 – Cannot find the static member ‘WatermakrTextProperty’ on the type ‘TextBoxWatermarkHelper’
- Chapter 18 – ComputedStartOffsetProperty on type RangeSelector
[...] what would it look like if you built WPF controls using F# ? If yes, head over to Matt’s blog where he has translated almost all of the examples in my book WPF Control Development Unleashed to [...]
I’m very much interested in F# but have been disappointed because even MS guys recommended to use C# and GUI-Builder for GUIs and then interface with F#. So Your posts are very motivating for me. Would you recommend your approach for a hobby programmer? BR
Hi Mike,
It depends on which programming paradigm you find works best for you. I prefer F# hands down. GUI designers add a lot of useless cruft to the code rendering them unusable, and C#/XAML requires a lot of ceremony. I find that entire F# programs can be elegantly expressed in a single page of code. John Liao’s blog at http://jyliao.blogspot.com/ has a ton of really great examples of F#/WPF.
Hope this helps, and happy coding.
Matt