This is a migrated thread and some comments may be shown as answers.
RadPanelBar selected item expanding/collapse issue
3 Answers 124 Views
This is a migrated thread and some comments may be shown as answers.
Manish Agarwal
Top achievements
Rank 1
Manish Agarwal asked on 03 Dec 2009, 11:38 AM
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

3 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 09 Dec 2009, 01:17 PM
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.
0
Clint Singer
Top achievements
Rank 1
answered on 24 Apr 2012, 07:22 PM
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
0
Petar Mladenov
Telerik team
answered on 27 Apr 2012, 07:32 AM
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 >>

Asked by
Manish Agarwal
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
Clint Singer
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or