Open hashitha opened 6 years ago
You can pass it as a content, using the new DynamicForm and passing the model in the Model property. Something like this:
var window = new MaterialWindow(new MaterialForms.MaterialDialog(LocalSettings)){Content = new DynamicForm{Model = YOURMODEL};
await window.Show();
This definitely needs to be supported from the library. Right now the only way to show a form is to include the DynamicForm control in your xaml tree, which is a pain. The old MaterialWindow and MaterialDialog are a hardcoded mess, so it's best to stay away from them.
Because the content of the form is left abstract, there needs to be a window host and a dialog host both of which have a dynamic form as their child and some infrastructure to support it. This can be reused for any model.
Luckily, this will be quite easy, since the heavy work of generating the contents is handled by DynamicForm. All that's left to do is create two wrappers:
Window
DynamicForm Model=Window.Model
Dialog
DynamicForm Model=Dialog.Model
and these wrappers can be used anywhere.
The API will be really simple, I'm considering also adding some static helpers:
var mySettings = new Settings();
DynamicForm.ShowWindow(mySettings);
DynamicForm.ShowDialog(mySettings);
// Note that we don't need to wrap mySettings. DynamicForm accepts objects, types, IFormDefinitions inherently!
I have an assignment for university right now but within the next 24 hours I will add this.
Thanks @hashitha. Also thanks to @redbaty for the continuous contribution!
Is it possible to show a window for a class like this
using something like this code