This is a migrated thread and some comments may be shown as answers.

ExpandMode Single and not allowing to collapse active panelbaritem

7 Answers 123 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
meteorrr
Top achievements
Rank 1
meteorrr asked on 03 Jun 2010, 11:12 AM
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.

7 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 07 Jun 2010, 01:43 PM
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.
0
meteorrr
Top achievements
Rank 1
answered on 11 Jun 2010, 10:59 PM
I figured it out by myself :) anyway - big thanks for a solution - it was exactly was I was expecting to do!
0
Nikolay Velizhanin
Top achievements
Rank 1
answered on 03 Nov 2010, 01:15 PM
It does not work in last release. Because PreviewCollapsed event occurs early than PreviewExpanded event :(
0
Nikolay Velizhanin
Top achievements
Rank 1
answered on 08 Nov 2010, 10:19 AM
UP!
0
Zarko
Telerik team
answered on 08 Nov 2010, 03:53 PM
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
0
Nikolay Velizhanin
Top achievements
Rank 1
answered on 09 Nov 2010, 09:43 AM
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>
0
Zarko
Telerik team
answered on 09 Nov 2010, 02:30 PM
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
Tags
PanelBar
Asked by
meteorrr
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
meteorrr
Top achievements
Rank 1
Nikolay Velizhanin
Top achievements
Rank 1
Zarko
Telerik team
Share this question
or