F# 3.0 brings the new type providers feature which enables a lot of different applications. Today I’m happy to announce that the FSharpx project brings you a WPF designer for F# in the Visual Studio 11 beta.
A big kudos to Johann Deneux for writing the underlying XAML type provider.
- Create a new F# 3.0 Console application project
- Set the output type to “Windows Application” in the project settings
- Use nuget and install-package FSharpx.TypeProviders.Xaml
- Add references to WindowsBase.dll, PresentationFramework.dll, System.Xaml.dll and PresentationCore.dll
- Add a Xaml file to your project. Something like this:
- Now you can access the Xaml in a typed way:
- Start the project
Enjoy!
BTW: No code generation needed is for this. No more nasty *.xaml.cs files.
BTW2: Try to change the name of Button1 in the Xaml and press save.
Amazing, man! Congrats!
Comment by Rodrigo Vidal — Thursday, 22. March 2012 um 19:31 Uhr
[…] WPF Designer for F# (Steffen Forkmann) […]
Pingback by Dew Drop – March 23, 2012 (#1,293) | Alvin Ashcraft's Morning Dew — Friday, 23. March 2012 um 13:34 Uhr
Wow, this is really cool.
Thanks for your work!
Comment by Daniil — Tuesday, 27. March 2012 um 19:16 Uhr
I chose to learn fsharp bc of type providers. We are only seeing the tip of the iceberg…
Comment by Nicolas — Friday, 20. April 2012 um 20:03 Uhr
Hi Steffen,
One thing I ran into with this is that Visual Studio sometimes doesn’t pick up when the XAML has changed — it doesn’t always rebuild when you change the XAML and re-run the project. I don’t think this is necessarily a type provider issue, more likely a F# project system issue, but if any of your readers come across it, the workaround is to clean the project before re-running.
Comment by Ivan — Monday, 30. April 2012 um 2:29 Uhr
[…] plus there are a couple of things that may not be quite so obvious! (This example is based on Steffen Forkmann’s WPF Designer for F# announcement, which is in turn based on Johann Deneux’ XAML type […]
Pingback by Mindscape Blog » Blog Archive » Using WPF Elements from F# — Monday, 30. April 2012 um 3:07 Uhr
[…] FSharpx.TypeProviders.Xaml which includes a type provider for XAML files and therefor enables to use Visual Studios’s WPF Designer from F#. [Read more] […]
Pingback by FSharpx type providers are available as separate nuget packages » Rash thoughts about .NET, C#, F# and Dynamics NAV. — Wednesday, 26. September 2012 um 20:21 Uhr
Is it possible to do code behind with this. For example if you have a custom user control which you want to add behaviour to via f# is it possible to use this technique so that when you add you’re custom control to the palette the code behind additions are also added?
Comment by Brad Phelan — Sunday, 23. December 2012 um 19:04 Uhr
Merci beaucoup pour cette explication !
Comment by dsb29 — Tuesday, 8. January 2013 um 10:45 Uhr
I really like this. Thanks Steffen.
I used it for an F#J article “Create World … and other 3D”, substituting the C# xaml plumbing with this clean technique. My intro to it was the short blurb in Expert F# 3.0.
Have you gotten other user experience feedback?
Comment by Art Scott — Friday, 15. February 2013 um 0:12 Uhr
[…] Steffan Forkmanm’s post for more information about this. Lets also not forget about first class events and the […]
Pingback by F# end to end | FourEightThree — Saturday, 23. February 2013 um 18:46 Uhr
[…] development completely in F#. Steffen Forkmann has an excellent blog post about its usage “WPF Designer for F#“. It is probably one of my favorite posts about F# at all, it shows a real beauty […]
Pingback by WPF MVVM with Xaml Type Provider | Sergey Tihon's Blog — Saturday, 27. April 2013 um 18:39 Uhr
Great work, but it’s giving an error:
“The type FrameworkElement is not compatible with the type Window” in this line at “loadWindow”:
(new Application()).Run(loadWindow())
XAML compiles, but Needs the added Name Attribute in the root element as noted on the download website.
Comment by Wolfgang — Monday, 28. October 2013 um 21:16 Uhr
Thanks a lot..And how can i invoke my WPF Application from F#.. (i am having a project with Window.XAML and Window.XAML.cs .. need to invoke initialisecomponent() of Window.XAML.cs..
Regards,
Paul Ra Je
Comment by paul ra je — Monday, 24. February 2014 um 4:48 Uhr