fsprojects-archive / zzarchive-FSharp.Desktop.UI

F# MVC framework for WPF.
http://fsprojects.github.io/FSharp.Desktop.UI/
Other
81 stars 21 forks source link

Derived properties in WinForms #23

Open john-patterson opened 7 years ago

john-patterson commented 7 years ago

Even though this is a WPF framework, we're fitting it for WinForms. I know there's a [<DerivedProperty>] that Binding.OfExpression uses to do multi-way binding in the case of computed properties. In WinForms the Binding.OfExpression does not work because, I assume, WinForms is not compatible with the WPF binding framework.

I made a [<DerivedFrom(string array)>] attribute that lets you mark the direct dependencies of the computed properties on your model and hijacked the body of the Intercept method on the IIntercepter on the Model, so that when a setter is called, I check to see if there are any children pointing to me as a dependency.

I am still working on a couple nice-to-haves like transitive dependency resolution and memoizing reflection results, but it mostly works. Is this something that could be made into a pull request? I know it is a little strange thematically as this is a WPF framework.

smoothdeveloper commented 7 years ago

@john-patterson the good thing about this repository is that the name itself doesn't imply it is WPF specific :)

I'm also using winforms and I'd be interested if you could push samples in your fork.

john-patterson commented 7 years ago

@smoothdeveloper Sure thing. I just pushed what I have so far to my fork. https://github.com/john-patterson/FSharp.Desktop.UI/commit/96dfc6d1e1702c5b29a1644a9972d3b3c0e1a9b8

I have a unit test ready for transitive dependency, but I'm still working on implementing. :)