RadPanelBar selected item expanding/collapse issue

4 posts, 0 answers
  1. Manish Agarwal
    Manish Agarwal avatar
    44 posts
    Member since:
    Sep 2009

    Posted 03 Dec 2009 Link to this post

    Hi

    I am using a RadPanelBar with Hierarchical Data.I want to have first item by default selected when i open that page initially.
    I have used "

    EngagementList_LayoutUpdated" this method to open the selected item
    But in this case i am not able to collapse that selected item.
    I have also use "PreviewCollapsed" method then also "LayoutUpdatedLayout" fires in the end.

    Please suggest me ASAP how to resolve the issue .Plese mention some code also so that i can better understand.

    Regards
    Charu Pahuja

  2. Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 09 Dec 2009 Link to this post

    Hi Manish,

     You can attach to the ItemContainerGenerator.StatusChanged event and expand the item that you need as soon as its container has been generated:

    public MainPage()
    {
        InitializeComponent();
        myPanelBar.ItemContainerGenerator.StatusChanged += new EventHandler(ItemContainerGenerator_StatusChanged);
    }

    void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
    {
        Telerik.Windows.Controls.ItemContainerGenerator generator = sender as Telerik.Windows.Controls.ItemContainerGenerator;
        if (generator != null &&
    generator.Status == Telerik.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
        {
            (generator.ContainerFromIndex(0) as RadPanelBarItem).IsExpanded = true;
            myPanelBar.ItemContainerGenerator.StatusChanged -= ItemContainerGenerator_StatusChanged;
        }
    }

    Let me know if this helps.

    All the best,
    Tihomir Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Clint Singer
    Clint Singer avatar
    133 posts
    Member since:
    Oct 2012

    Posted 24 Apr 2012 Link to this post

    Hi,

    I was wondering if this is still the recommended way to open the first item in the RadPanelBar or has anything improved in the latest version of the framework?

    Cheers,
    Clint
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 27 Apr 2012 Link to this post

    Hi Clint Singer,

     This is a very old post. In Silverlight 4, you can take advantage of telerik's ContainerBindings and bind the IsExpanded / IsSelected property of the RadPanelbar or RadTreeView ( RPB inherits from RTreeView) to a boolean property from your ViewModel. In Silverlight 5, you can do take advantage of StyleBindings, the same way you can do it in WPF 4:

    <Style TargetType="telerik:RadTreeViewItem">
          <Setter Property=IsExpanded Value="{Binding ShouldBeExpanded, Mode=TwoWay}"
    </Style>
    Please let us know if you need further assistance on this.

    All the best,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top