Skip to content
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

WPF Helpers: GetFocusedElement, GetSelectedElement(s), DragDrop, etc. :: A global approach :: #594

Closed
YkTru opened this issue Jan 18, 2024 · 1 comment

Comments

@YkTru
Copy link

YkTru commented Jan 18, 2024

I know this is a common topic/problem in MVVM, but I still can't get my head around it, so beware, I may sound confused. (when I say "log", I mean in-app TextBlock logging, not Serilog)

  • Is it a good idea to make a "WPF Helper" module to help with various harder to accomplish MVVM task? (get focuses/selected element for logging, set the border color of an element in a file to depend on an element in another file etc.)
  • Does this Elmish sample can be made as a function (service) so we won't have to repeat "GotFocus/LostFocus etc." for each element needed such behaviors? (idem for logging)
  • Again with a "global approach" in mind, would you advise to make a global anonymous style (App.xaml) targeting x:Type UIElement (or FrameworkElement?) where I can put behaviors in a template (eg.: "LogWhenSelected/Focused", "ChangeBorderColorOnExternalEvent", "DragDropBehavior", etc)?

Could you provide advices on how to organize such a module + some code too please?

Thank you

@YkTru YkTru changed the title WPF Helpers in Elmish.Core: GetFocusedElement, GetSelectedElement(s), Update{Property}OnFocus, etc. WPF Helpers in Elmish.Core: GetFocusedElement, GetSelectedElement(s), Update{Property}OnFocus, etc. :: A global approach :: Jan 19, 2024
@YkTru YkTru changed the title WPF Helpers in Elmish.Core: GetFocusedElement, GetSelectedElement(s), Update{Property}OnFocus, etc. :: A global approach :: WPF Helpers: GetFocusedElement, GetSelectedElement(s), Update{Property}OnFocus, etc. :: A global approach :: Jan 19, 2024
@YkTru YkTru changed the title WPF Helpers: GetFocusedElement, GetSelectedElement(s), Update{Property}OnFocus, etc. :: A global approach :: WPF Helpers: GetFocusedElement, GetSelectedElement(s), DragDrop, etc. :: A global approach :: Jan 19, 2024
@TysonMN
Copy link
Member

TysonMN commented Jan 21, 2024

My impression is that these issues are all independent of Elmish.WPF. Therefore, I don't think it would be a good idea to have helpers in Elmish.WPF for them.

My first recommendation would be to write the code you want and organize it in a reusable way. If this became a large amount of code, then consider using an existing library that provides much of the same functionality.

@YkTru YkTru closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants