ExpandMode Single and not allowing to collapse active panelbaritem

8 posts, 1 answers
  1. meteorrr
    meteorrr avatar
    7 posts
    Member since:
    Mar 2008

    Posted 03 Jun 2010 Link to this post

    I configured PanelBar to display only one PanelBarItem by setting PanelBar.ExpandMode to 'single', but I don't like this behavior that it's still possible to collapse this single PanelBarItem. Is it possible to disallow collapsing single visible panel by setting up this control somehow or could you give me any clue how to do it?
    Best regards
    T.
  2. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 07 Jun 2010 Link to this post

    Hello Tomo,

     The key here is to play a little bit with PreviewExpanded and PreviewCollapsed events of RadPanelBar. I've attached one possible solution to your scenario. Have a look at it and let me know if you need further assistance.

    Greetings,
    Kiril Stanoev
    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
  4. meteorrr
    meteorrr avatar
    7 posts
    Member since:
    Mar 2008

    Posted 11 Jun 2010 Link to this post

    I figured it out by myself :) anyway - big thanks for a solution - it was exactly was I was expecting to do!
  5. Nikolay Velizhanin
    Nikolay Velizhanin avatar
    13 posts
    Member since:
    Feb 2010

    Posted 03 Nov 2010 Link to this post

    It does not work in last release. Because PreviewCollapsed event occurs early than PreviewExpanded event :(
  6. Nikolay Velizhanin
    Nikolay Velizhanin avatar
    13 posts
    Member since:
    Feb 2010

    Posted 08 Nov 2010 Link to this post

    UP!
  7. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 08 Nov 2010 Link to this post

    Hello Nikolay Velizhanin,

     There have been some changes in the RadPanelBar and now by design the PreviewCollapsed event occurs  before the PreviewExpanded event(in order to expand an item you should collapse the other first). To get the sample project working you should use the Selected(or PreviewSelected) event instead of the PreviewExpanded event. I've updated the attached project, so could you please examine it and if you have further questions feel free to ask?

    Regards,
    Zarko
    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
  8. Nikolay Velizhanin
    Nikolay Velizhanin avatar
    13 posts
    Member since:
    Feb 2010

    Posted 09 Nov 2010 Link to this post

    It does not work with binding when I programmatically set IsExpanded = true, IsSelected = true on my model object. It does not expanded :(


    <UserControl x:Class="SGP.GisPortal.Client.UI.DataNavigator.NavBarLayoutControl"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerikCore="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
        xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation">
        
        <UserControl.Resources>
            <telerikCore:ContainerBindingCollection x:Name="containerBindings">
                <telerikCore:ContainerBinding PropertyName="IsExpanded"
                                              Binding="{Binding IsExpanded,  Mode=TwoWay}" />
                <telerikCore:ContainerBinding PropertyName="IsSelected"
                                              Binding="{Binding IsSelected,  Mode=TwoWay}" />
            </telerikCore:ContainerBindingCollection>
            
            <DataTemplate x:Key="contentTemplate">
                <ContentPresenter Content="{Binding}" />
            </DataTemplate>

            <Style x:Key="headerPanelStyle" TargetType="StackPanel">
                <Setter Property="Margin" Value="5" />
                <Setter Property="IsHitTestVisible" Value="False" />
                <Setter Property="Orientation" Value="Horizontal" />
                <Setter Property="Height" Value="30"/>
            </Style>

            <Style x:Key="headerTextStyle" TargetType="TextBlock">
                <Setter Property="Margin" Value="10,0,0,0" />
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>
            
            <telerikCore:HierarchicalDataTemplate x:Key="headerTemplate"
                                                  ItemsSource="{Binding Path=ItemControls}"
                                                  ItemTemplate="{StaticResource contentTemplate}"
                                                  telerikCore:ContainerBinding.ContainerBindings="{StaticResource containerBindings}">
                <StackPanel Style="{StaticResource headerPanelStyle}">
                    <Image Source="{Binding Path=Item.ItemIcon}" Stretch="None" Height="32" Width="32" />
                    <TextBlock Text="{Binding Path=Item.ItemTitle}" Style="{StaticResource headerTextStyle}" />
                </StackPanel>
            </telerikCore:HierarchicalDataTemplate>
        </UserControl.Resources>
        
        <Grid x:Name="LayoutRoot" Background="White">
            <telerikNavigation:RadPanelBar x:Name="pnlMain" ExpandMode="Single"
                                           VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                                           ItemTemplate="{StaticResource headerTemplate}" />
        </Grid>
    </UserControl>
  9. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 09 Nov 2010 Link to this post

    Hello Nikolay Velizhanin,

     With binding you still have to catch the PreviewCollapsed event to check if you should handle it. I've updated the attached project, so please examine it and tell me if it works for you.

    Regards,
    Zarko
    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
Back to Top
DevCraft banner