Unplanned
Last Updated: 08 Mar 2022 08:06 by Stenly
Stenly
Created on: 08 Mar 2022 08:06
Category: CardView
Type: Feature Request
1
CardView: Expose Expand and Collapse events

Expose Expand and Collapse events, which will occur when a RadCardViewItem element is either collapsed or expanded.

Currently, to achieve this behavior, subscribe to the Loaded event of the RadCardView control, and add two new event handlers via the AddHandler method.

For the first handler, which will be responsible for occurring when expanding, pass as a first argument RadExpander.ExpandedEvent. As a second parameter, create a new RoutedEventHandler instance with a method, which will fire the custom logic when the internal RadExpander element of the current RadCardView is getting expanded.

For the second added event handler, which will be responsible for the collapsing logic, the same approach as the abovementioned one could be used.

The following code snippet shows this approach's implementation:

private void CardView_Loaded(object sender, RoutedEventArgs e)
{
    this.cardView.AddHandler(RadExpander.ExpandedEvent, new RoutedEventHandler(Expanded));
    this.cardView.AddHandler(RadExpander.CollapsedEvent, new RoutedEventHandler(Collapsed));
}

private void Expanded(object sender, RoutedEventArgs e)
{
    var expander = e.OriginalSource as RadExpander;
    //Get clicked CardViewItem element
    var cardViewItem = expander.ParentOfType<RadCardViewItem>();
}

private void Collapsed(object sender, RoutedEventArgs e)
{
    var expander = e.OriginalSource as RadExpander;
    //Get clicked CardViewItem element
    var cardViewItem = expander.ParentOfType<RadCardViewItem>();
}

 

0 comments