WPF-Forge/Forge.Forms

Include examples of how to send form data to e.g. back-ends

KrisJanssen opened this issue · 1 comments

Hi guys,

Forge seems to be a very nice and potentially useful project. The fact that the demo apps are included to not only demonstrate Forms but also the application piece (e.g. the routing) is nice.

However, coming from creating monolithic WinForms based applications, I struggle to infer how I would achieve something like adopting the codebase to e.g. do CRUD operations on any kind of storage (a DB, Sharepoint, ...). It is not so much the interaction with these back end that is a problem but rather how to create e.g. a service and then properly register that so the forms can leverage it.

A sort of dummy example here would be extremely helpful.

Hi @KrisJanssen!

The fact that the demo apps are included to not only demonstrate Forms but also the application piece (e.g. the routing) is nice.

I'm glad you found it useful. Though the application "framework" is not something I'd use in production as a dependency because it's stiff and opinionated. As you have noticed, it relies on a DI engine like NInject and other stuff, which is a bad design smell. Instead, I'd take some parts I like and simply add organize those in my project and fit them as needed.

Sadly the same goes for Forge.Forms. It relies on big UI toolkits and is a pain to manage dependencies.

It is not so much the interaction with these back end that is a problem but rather how to create e.g. a service and then properly register that so the forms can leverage it.

Are you using the MVVM pattern for your app? If you're using that, then your form model can raise actions and your ViewModel should handle actions by implementing IActionHandler. It should look like this:

class MyViewModel : INotifyPropertyChanged, IActionHandler
{
    // Suppose we have the DB from somewhere...
    public IDatabase Database { get; set; }

    public void HandleAction(IActionContext actionContext)
    {
        if (actionContext.Action is "save")
        {
            MyFormModel model = (MyFormModel)actionContext.Model;
            this.Database.Save(model);
        }
    }
  
    ...
}

I'm not sure if this is what you have asked. Please let me know if you need further explanation.