Skip to content

ProgressRing does not collapse if IsActive="False" #3212

@davikor

Description

@davikor

I recently updated my project from MahApps 1.5 to 1.6.1 and discovered that the ProgressRing control does not collapse anymore, when its IsActiveproperty is set to False.

Since I position this control on top of other controls, I cannot interact with the underlying controls anymore, or at least not with the parts that are covered by the progress ring.

I think this behavior change is a bug, because ProgressRings are likely to be used on top of other controls, therefore the old collapse behavior was better suited in my opinion.

As a workaround I use the following Blend Behavior, which sets the Visibility-property to collapsed when IsActive changes to false

public class CollapseBehavior : Behavior<ProgressRing>
{
    protected override void OnAttached()
    {
        base.OnAttached();
        SetVisibility();
        DependencyPropertyDescriptor.FromProperty(ProgressRing.IsActiveProperty, typeof(ProgressRing))
            .AddValueChanged(AssociatedObject, OnIsActiveChanged);
    }

    protected override void OnDetaching()
    {
        base.OnDetaching();
        DependencyPropertyDescriptor.FromProperty(ProgressRing.IsActiveProperty, typeof(ProgressRing))
            .RemoveValueChanged(AssociatedObject, OnIsActiveChanged);
    }

    private void OnIsActiveChanged(object sender, EventArgs eventArgs)
    {
        SetVisibility();
    }

    private void SetVisibility()
    {
        AssociatedObject.Visibility = AssociatedObject.IsActive ? Visibility.Visible : Visibility.Collapsed;
    }
}

However, I would prefer to remove this behavior again with an upcoming version of MahApps.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions