PanelBar selected/collapsed

2 posts, 0 answers
  1. Frederic
    Frederic avatar
    1 posts
    Member since:
    Apr 2017

    Posted 09 May Link to this post

    Searched forum and couldn't find a related issue. I'm using the PanelBar as Accordion. When a Panel bar item is selected it is displayed, but when the same panel bar item is selected agan it's collapsed. Can this behavior be prevented

    If a panelbar item is already selected it stay selected and do not collapses. That means I want "ALWAYS" a panel bar item to be visible.

    I'd rather prefer a XAML only solution.

    Regards

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1404 posts

    Posted 11 May Link to this post

    Hello Frederic,

    I will post the answer from your support ticket also here in the forum.

    "To achieve your requirement you can subscribe for the PreviewCollapsed event of the RadPanelBar control and handle it when all items are collapsing. Here is an example in code for this approach:

    private void RadPanelBar_PreviewCollapsed(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        var panelBar = (RadPanelBar)sender;
        var areAllItemsCollapsing = panelBar.Items.OfType<RadPanelBarItem>().All(x => !x.IsExpanded);        
        e.Handled = areAllItemsCollapsing;
    }
    "

    I am afraid that, I can't suggest you a XAML-only approach.

    Regards,
    Martin
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top