F# and WPF

Dear functional programmers,

this is a short trip to desktop development in .Net.

mvvm

If you like F#, you will design some models with record types and maybe you retrieve their items with type providers

Now you bind the array to a DataGrid and you can show a nice UI.

 

Problem

What if you want to update a status message from the app logic to some items of the UI?

Do you have to refactor all those records into plain old objects (= classes)?

Compositional trick

Well, that’s not need! You simply leverage the compositional property of the binding path in .Net implementation of the MVVM pattern.

So you just add a new ui member to the F# record type

and you define the binding in a grid column

Happy coding, cheers!

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s