-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sample] "SubModelSelectedItem" StaticVM equivalent? (+ a new sample proposition) #613
Comments
@marner2 My intuitive guess would be to replace "subModelSeqBindingName : string" by ViewModelArgs is that right? Should a SubModelSelectedItemT be added to the library, or is there another way around by composing? @xperiandri? (I havent found any equivalent in ElmishUno ) |
Looks like it is not implemented correctly in ElmishUno |
Maybe you avoid its usage as |
Do you mean this part?
I didn't think of another way since I was trying to stick to the same API as the sample but for a static Vm, what would you suggest instead, Binding.SubModelT.opt or SubModelSeqKeyedT? |
I have created a simple, abstract, yet concrete example to illustrate where I am currently stuck, please feel free to edit the code: https://github.com/YkTru/Test_SubModelSelectedItem — (Once I resolve the main issues, I plan to add a DataTemplateSelector.) • This is the sample I am trying to partially adapt to a Static ViewModel. • I’ve marked the sections where I am having trouble with "SelectedItem" using "###". I attempted to use SubModelSeqKeyedT without successs. • [Q2] Since I am using Id for each component, should I be using SubModelSeqKeyed instead of SubModelT for TextBoxABC components? Any other things I might not be doing right? • [Q3] Does using a separate FsWPF file seem like a good approach to you? I’m considering creating another project named FsWPF.proj that references Core.proj instead, to serve as code-behind for behaviors, converters, DataTemplateSelector, etc. of which there are many (at least in my projects). Do you see a more "Elmish/Elm/FP" way to handle or interact with these WPF features? • [Q4] I think that once this sample is refined and corrected, it could offer valuable insights into several Elmish.WPF features—particularly a more complete example of how to use a Static VM—compared to the more basic sample, as well as the interaction with WPF using unions. What’s your opinion? Thank you. |
[update] In a desperate attempt, I tried to only bind to a single element as in the SubModelSelectedItem sample but still, at runtime, when I select any TextBoxA the border of the ListView goes red and nothing happens.
|
I don't have much time to review stuff in too much detail at the moment, but remember that in general "old-style" bindings work with the new static view models. They just cast your property to I can review this in more detail at a later point. Let me know if this helps. I had originally avoided migrating this binding because of weird caveats with types, and the fact that the old one works just fine beings it's kind of a band-aid the way it is. |
[update] I finally was able to pattern match submodels on a parent model, using a mix ("band-aid") of static and dynamic bindings as you proposed. (I haven't pushed yet, since I want to add a DataTemplateSelector) @marner2: Do you think it would be worth opening a PR to propose this as a sample once I add the DataTemplateSelector? It could demonstrate some ElmishWPF techniques on how to build a basic form designer using pattern matching for different components/submodels. (In fact, I think it would be a good extension of the subModelSelectItem sample without adding too much complexity or cognitive overload.) Whenever you have time, could you please update the "old-style" bindings in the PR sample to an entirely newer/modern static bindings style? (also, #606 (comment), you were looking to eventually revise the static bindings approach/helpers? "In fact, I'm tempted to remove the model ones as you can always introduce it with a call to Bindings.mapMsgWithModel and just disregard the original msg (which is the obj parameter). Thank you |
(I made a PR) |
Hello,
From this sample, I can't get a Static VM version to work.
I tried looking at the source code:
But I'm not sure how to translate the equivalent (especially subModelSeqBindingName : string)
Here's what I've got now:
DynamicVM
SelectedEntity“ |> Binding.subModelSelectedItem(”Entities”, (fun m -> m.Selected), Select)
StaticVM
Thank you very much
[edit] proposition for a new sample using Static VM + how to deal wit Union of different components (DataTemplateSelector, IValueConverter, SubModelSelectedItem)
The text was updated successfully, but these errors were encountered: