How to collapse radCollapsiblePanel without firing Collapsed event...

0 Answers 30 Views
CollapsiblePanel
Alessandro
Top achievements
Rank 2
Iron
Iron
Iron
Alessandro asked on 09 Jan 2024, 11:48 AM

Hi all,

I want to set the initial state of a radCollapsiblePanel to expanded or collapsed. Then, I want to associate an event handler to handle user interaction that can expand or collapse the panel. I perform some operations to set the initial state. When I attach the event handler for the collapsed state, the event is triggered even if the user has not interacted with the panel.

I don't understand why.

Suggestions

Regards

Alessandro

Alessandro
Top achievements
Rank 2
Iron
Iron
Iron
commented on 09 Jan 2024, 03:52 PM

After looking at the Telerik control source code, I found the problem. The OnCollapsed event is sent when the collapse/expand animation completes. So if you set the isExpanded property to false in your application and after that you set eventhandler for "Collapsed" for example:


//not working (the PnlCollassabile_CollapsedExpanded handler is called even if is set *after* the initial collapse by code
collapsiblePanel.IsExpanded = false;
collapsiblePanel.Collapsed += PnlCollassabile_CollapsedExpanded;

//it works because i'm waiting the animation to complete
collapsiblePanel.IsExpanded = false;
  while (collapsiblePanel.IsAnimating)
      await Task.Delay(100);
collapsiblePanel.Collapsed += PnlCollassabile_CollapsedExpanded;

hope is useful for others

Regards

Nadya | Tech Support Engineer
Telerik team
commented on 11 Jan 2024, 08:57 AM

Hello, Alessandro,

It seems that you have already found how to accomplish the desired behavior that you would like to have with RadCollapsiblePanel. Thank you for sharing your solution with the community!

In case you have any other questions do not hesitate to contact us.

No answers yet. Maybe you can help?

Tags
CollapsiblePanel
Asked by
Alessandro
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or