[Samples] from dynamic bindings to static VM ("SubModelOpt" sample) #607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I propose to convert all actual samples using dynamic bindings to static bindings, or make 2 folders and put appropriate samples in each: "Dynamic bindings", "Static bindings"
I've run this new sample and everything works as expected, but I don't have enough knowledge to know if I've overlooked anything (e.g., not using the right helpers for better performance, missing relevant “>> Binding.x” (e.g., boxT, addLazy, etc.).
I've converted 2-space indentation to 4-space idiomatic indentation (in fact, why do all samples use 2-space indentation? it's not practical to refactor everything to 4-space if you need to explore/reuse/etc. the sample).
I suggest using (not idiomatic I know) “_Binding” for the binding helpers and “_ViewModel” for the static VM to improve readability and intellisense experience (i.e. writing “_V” filters automatically to get all static VMs; I do the same in WPF for "_Behaviors", "_Converter", "_ResourceDict" etc. which helps a lot IMO).
I suggest skipping 2 lines between the module and the associated ViewModel, and 3 between the previous ViewModel and a new module; I suppose this too is not idiomatic, but IME it helps a lot with readability/navigation.
I can do this kind of conversion from dyamic to static VM for all samples if you think it's relevant, it helps me learn at the same time. (I also intend to provide samples for what I think a “basic abstract project structure” that can scale well might look like (mostly based on previous discussions) if you think it's relevant too (?); this could at least be a starting point for possible samples of this kind, since I'm not an expert. Would another folder in the sample repo named “Project Structures” be relevant then?)
be replaced by:
and same for all other binding helpers?
DataContext="{Binding Form1}"
(and Form2) is the only binding unable to resolve at compile time (though at runtime it works fine):codelens says:
(Form1_ViewModel).Path=
, is there a way to access(App_ViewModel).Path=
here?