IsExpanded Question

2 posts, 0 answers
  1. Steve
    Steve avatar
    37 posts
    Member since:
    May 2007

    Posted 20 Apr 2010 Link to this post

    I have a MVVM scenario where my data includes the header and isexpanded
    ie
    PanelData = new ObservableCollection<Sample> 
                                { 
                                    new Sample {HeaderName = "Panel1", Content="Hello Panel1", IsExpanded = false}, 
                                    new Sample {HeaderName = "Panel2", Content="Hello Panel2", IsExpanded = true
                                }; 

    In the xaml, I have the following:
    <Controls:HierarchicalDataTemplate x:Key="MyTemplate"
                    <telerikNavigation:RadPanelBarItem  IsExpanded="{Binding IsExpanded}"> 
                        <telerikNavigation:RadPanelBarItem.Header> 
                            <TextBlock Text="{Binding HeaderName}" Margin="5 4 5 5" /> 
                        </telerikNavigation:RadPanelBarItem.Header> 
     
                        <TextBlock Text="{Binding Content}"/> 
                    </telerikNavigation:RadPanelBarItem> 
                </Controls:HierarchicalDataTemplate> 
     
    <telerikNavigation:RadPanelBar BorderBrush="#9098a3" BorderThickness="1" Margin="5" 
                                               ItemsSource="{Binding Path=PanelData}" 
                                                 ItemTemplate="{StaticResource MyTemplate}"
                </telerikNavigation:RadPanelBar> 

    The problem is that it's creating a panel within a panel on each item:

    See attached.  I have tried several ways but cannot figure out how to control the IsExpanded piece without ending up with this scenario.  Otherwise, I wouldn't add the RadPanelBarItem in the template.  All other ways have failed me so far though.

    Thank you

  2. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 23 Apr 2010 Link to this post

    Hello Steve,

    In order to bind Sample.IsExpanded property to RadPanelBarItem.IsExpanded you have to use ContainerBinding technique.You can read more about it here. The example is with TreeView but it's the same in your case.
    If you have further questions please ask us.


    All the best,
    Miro Miroslavov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
Back to Top