# How to close Radzen panel from code

**URL:** <https://forum.radzen.com/t/how-to-close-radzen-panel-from-code/6019>\
**Category:** Radzen.Blazor Components\
**Created:** [December 14, 2020, 6:28pm UTC](https://forum.radzen.com/t/how-to-close-radzen-panel-from-code/6019 "2020-12-14T18:28:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Davison](https://forum.radzen.com/user_avatar/forum.radzen.com/richard_davison/32/5144_2.png) [@Richard\_Davison](https://forum.radzen.com/u/Richard_Davison)\
**Post date:** [December 14, 2020, 6:28pm UTC](https://forum.radzen.com/t/how-to-close-radzen-panel-from-code/6019/1 "2020-12-14T18:28:38Z")

</div>

I am using trying to use the panel to show/hide a set of configuration items from on a parent component that flow to the child on a button click I want to be able to collapse the RadzenPanel in this event but I am not able to do so. Warnings about setting a components parameters outside the component etc.

---

<div class="post-metadata">

**Author:** ![Richard\_Davison](https://forum.radzen.com/user_avatar/forum.radzen.com/richard_davison/32/5144_2.png) [@Richard\_Davison](https://forum.radzen.com/u/Richard_Davison)\
**Post date:** [December 14, 2020, 8:40pm UTC](https://forum.radzen.com/t/how-to-close-radzen-panel-from-code/6019/2 "2020-12-14T20:40:49Z")

</div>

```auto
<RadzenPanel @ref="ConfigPanel" Collapsed="@ShowCollapsed" AllowCollapse="true" class="bg-light"
             Expand=@(() => PanelCollapseChange("Expand")) Collapse=@(() => PanelCollapseChange("Collapse")) >
<HeaderTemplate> </HeaderTemplate>
<ChildContent></ChildContent>
</RadzenPanel>   
@code{

    public bool ShowCollapsed { get; set; } 

    void PanelCollapseChange(string Command)
    {
        if(Command == "Expand")
            ShowCollapsed = false;
        if(Command=="Collapse")
            ShowCollapsed= true;

    }
}

```

with this setup you can modify ShowCollapsed in code behind and it works as expected  
the trick is that even though we have this binding

```auto
Collapsed="@ShowCollapsed"

```

without the code in the on changed event things don't stay in sync -- initial open --\> close in code behind --\>open from the [-]' stays open and will not close from code behind again
