-
-
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
XAML type provider #142
Comments
Replying to #141 (comment).
Yes, that is my thinking as well. The magic string approach isn't that bad, especially when you consider that essentially all GUI frameworks do something similar. I don't have any current plans to look into this, but I hope to do so eventually. Thanks for the links and short descriptions :) |
I agree. Magic strings definitely isn't the biggest problem we deal with. Nevertheless GUI breaks from time to time because a string depended on some identifier that was refactored (renamed). Using dedicated local types for bindings and streamings, or running unit tests that checks with 'nameof', are examples of how to avoid or detect such breaking changes. I like doing heavy refactorings to keep my code tidy, so I also depend heavily on that kind of security around my code. It works. |
If you use design-time VMs (check the readme), the tooling might warn you if there's a binding from XAML that don't exist in the VM. Not sure if design-time VMs work with netcoreapp3.0 by the way, because it seems that the XAML designer currently doesn't support Project Code. |
Me too. My goal is to have all the magic strings be string literals passed into Elmish.WPF bindings. That way, I can't break anything with using Visual Studio's Refactor-Rename. After I make the changed described in #131 (comment), I will once again be achieving this goal with my work project. |
What is "Project Code"? |
I'm no expert, but the designer basically runs your project so that you get the design-time data you want. In the .NET framework designer there's a button to toggle it on/off. I can't find that button when using .NET Core. |
I do, but I don't reuse the runtime model for that. I find it much easier to simply create a class or two or three with properties and whatnots. My goal, obviously, is just to deliver some fake data for design time. I couldn't care less whether the runtime and design-time VM's are properly aligned in all manners. After all, there is no interactivity either, so why bother with a more complex model that includes the time aspect when the data is all static. The visual design generally becomes easier this way, at least for me. update Nov 2020 : Problems solved, I now use Elmish.WPF proper design time models. |
Some benefits of a using runtime model are 1) you're guaranteed to keep the design-VM props in sync with the bindings (since they're the same), giving you useful Intellisense and warnings when changing/renaming the bindings in Making a simple, separate design-time VM is a perfectly reasonable tradeoff, though. |
This issue is related to #13 |
In case its helpful, Pluralsight has a course about how to create a type provider. |
@cmeeren said:
But I cannot see a warning in the designer when the binding does not match the binding name on the VM. (see animation on sample project) |
I useful link it this issue is to the FsXaml project (which was lasted updated in 2018). |
For the record, I have a solution to this documented in #494. It involves replacing the type lists into an F# ViewModel type, implemented through a helper. This solution therefore leverages the types directly. It should work completely inline with the current solution. |
Very interesting. I am excited to try this. |
What about directly subclassing Command bindings could work the same way, with a subclass of EDIT: nevermind I see that most of the classes here are sealed and use other helpers to actually do the work. |
This issue spun out of #141 (comment).
The general question is
The text was updated successfully, but these errors were encountered: