Skip to content

Add IsVisible Binding to OffCanvas #84

Closed
@buist-sharris

Description

@buist-sharris

It could greatly simplify the use of the offcanvas if rather than needing a reference to it so one can call ShowAsync() and HideAsync(), if it an "IsVisible" property that could be bound. Behind the scenes, in the setter, it could call Show/Hide.

Some simple pseudo code to demonstrate.

<togglebutton IsSelected="@Model.IsShowingCanvas" />

<blazorbootstrap.offcanvas IsVisible="@Model.IsShowingCanvas"  />
private bool _isVisible;

[Parameter] public bool IsVisible
    {
        get => _isVisible;
        set
        {
            if (value == _isVisible)
            {
                return;
            }

            _isVisible = value;

            if (value)
            {
                ShowAsync();
            }
            else
            {
                HideAsync();
            }
        }
    }
    
public Task ShowAsync() {
    _isVisible = true;
    //rest of code
}   

public Task HideAsync() {
    _isVisible = false;
    //rest of code
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions