elmish / Elmish.WPF

Static WPF views for elmish programs
Other
428 stars 69 forks source link

[Bindings] `TwoWaySeq` #610

Open xperiandri opened 1 month ago

xperiandri commented 1 month ago

High-level description TokenizingTextBox from WCT modifies the collection supplied to ItemsSource. Hence changes must be propagated back to the model.

I've implemented TwoWaySeq binding in my fork See commits in https://github.com/Ecierge/Elmish.Uno/commits/eCierge/

Backport if you consider it useful

YkTru commented 1 month ago

Doesnt 'NotifyCollectionChangedEventArgs' bind you to .Net? I mean, why can't notification be done with Msg + updates as usual?

xperiandri commented 1 month ago

But the collection is being modified from the UI. So I need to know when it happened from UI

YkTru commented 1 month ago

I may be confused, so please correct me if I'm wrong, but my intuition is as follows:

1- if the library is to be linked to Net (which is inevitable for UNO/WPF), all Net functionality must be “hidden” (as in this file), i.e. the MVU part must not use anything from Net (with the exception of “Window” in “main”)

2- if I need to get data from the UI and “Mode=TwoWay” isn't enough, I use Behaviors to bind to events, or for any other scenarios (personnally, I use Behaviors a LOT to keep MVU independent and clean).

3- otherwise, I have an F# project called “[ProjectName].WPF.Fs” which depends on “[ProjectName].Core” (parallel to C# "[ProjectName].WPF") in which I do all my "WPF dependant" code; I used it recently to do some clean DataTemplateSelector code (for a Form Designer), and I think I'll do my behaviors in F# too (I really prefer the syntax + error handling).

Am I misunderstanding something? Is that the way to go @marner2?

xperiandri commented 1 month ago

Well, I do not argue that the API may be better than I implemented. The issue is that if an ObservableCollection is modified from UI you will never get such update. So we need to get it somehow

YkTru commented 2 weeks ago

@xperiandri Well, too bad our efforts to spark conversation aren't taken into account. I hope you'll continue to be interested in ElmishWPF/UNO and use it, otherwise I'll be very lonely..

Thank you for sharing your code and insights.

xperiandri commented 2 weeks ago

Maybe you become a maintainer of this repo? @YkTru

YkTru commented 2 weeks ago

Haha! I was thinking more of you!

You clearly understand the ins and outs of this library better than I do. I've been using F# since last October, so I'm in danger of breaking it all!