edongashi / WpfMaterialForms

Dynamically generated forms and dialogs in WPF
MIT License
51 stars 14 forks source link

Progress dialog #23

Open hashitha opened 6 years ago

hashitha commented 6 years ago

@EdonGashi is the following code still valid or are you planning on re-writing it

private async void ShowProgress(object sender, RoutedEventArgs e)
        {
            await TaskRunner.Run(async controller =>
            {
                for (var i = 1; i <= 100; i++)
                {
                    controller.Progress = i;
                    await Task.Delay(50);
                }
            }, new ProgressDialogOptions
            {
                Message = "Processing data..."
            });
        }
edongashi commented 6 years ago

Everything new is being added to a new namespace MaterialForms.Wpf. I see no reason to remove the old code; if it does what you need feel free to use it.

New progress bar will be a [Progress(Value="{Binding SomeProgressIndicator}")], which adds a new control, like [Action] does. This is more flexible than using a numeric property and displaying it as progress because with the resource syntax you can get data from elsewhere.

For example if a ViewModel does some IO operation we can easily track it using {ContextBinding Progress}.

redbaty commented 6 years ago

@EdonGashi Hey Edon, any reason why the progress attribute should be a control like[Action]and not a property bound attribute? I think this would only create confusion and it requires another property with [Field(IsVisible=False)] set 🤔

edongashi commented 6 years ago

Yeah I see the point that in most cases you will have a numeric property to track progress. I thought since you can get values from anywhere it would be more decoupled as an element.

Unrelated note: Element attributes can decorate classes and also have an InsertAfter flag which specifies that it will be displayed after the thing it decorates. For properties it adds the element after the field; for classes it adds the element after the form.

edongashi commented 6 years ago

Added the [Progress] attribute in feature/progress.