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

Recover Space

2 Answers 87 Views
Expander
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 21 May 2009, 05:21 PM
Is there a way to recover the area that was being used by the expander when the expander is collapsed?  I have the event captured and I have the contents set to Collapsed but the space is still left on the screen rather than yielding it to the other row in the grid.

 

<Window x:Class="WpfApplication1.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
        Title="Test" Height="350" Width="250" Background="Beige">  
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="Auto" /> 
            <RowDefinition Height="Auto" /> 
        </Grid.RowDefinitions> 
        <Image Grid.Row="0" 
               Name="imageBackground"    
               HorizontalAlignment="Left" 
               VerticalAlignment="Top" 
               Source="/WpfApplication1;component/Images/master.png"   
               Stretch="Uniform" MaxHeight="250" /> 
          
        <telerik:RadExpander x:Name="radExpander"   
                             Grid.Row="1" 
                             IsExpanded="True" 
                             telerik:StyleManager.Theme="Vista" 
                             VerticalAlignment="Stretch" HorizontalAlignment="Stretch"   
                             Collapsed="radExpander_Collapsed" Expanded="radExpander_Expanded">  
            <telerik:RadExpander.Header> 
                <TextBlock x:Name="expanderCaption" Foreground="#FFFFFFFF" Text="Test Box" 
                            Visibility="Visible" /> 
            </telerik:RadExpander.Header> 
            <telerik:RadExpander.Content> 
                <WrapPanel x:Name="imageContainer" Orientation="Horizontal">  
                    <Image Margin="12" Width="200" Height="64" Stretch="Uniform" Source="/WpfApplication1;component/Images/test.png" /> 
                    <Image Margin="12" Width="200" Height="64" Stretch="Uniform" Source="/WpfApplication1;component/Images/test.png" /> 
                </WrapPanel> 
            </telerik:RadExpander.Content> 
        </telerik:RadExpander> 
    </Grid> 
</Window> 
 

 

 

code:

 

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Data;  
using System.Windows.Documents;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Imaging;  
using System.Windows.Navigation;  
using System.Windows.Shapes;  
 
namespace WpfApplication1  
{  
    /// <summary>  
    /// Interaction logic for Window1.xaml  
    /// </summary>  
    public partial class Window1 : Window  
    {  
        public Window1()  
        {  
            InitializeComponent();  
        }  
 
        private void radExpander_Collapsed(object sender, RoutedEventArgs e)  
        {  
            if (imageContainer != null)  
                imageContainer.Visibility = Visibility.Collapsed;  
        }  
 
        private void radExpander_Expanded(object sender, RoutedEventArgs e)  
        {  
            if (imageContainer != null)  
                imageContainer.Visibility = Visibility.Visible;  
 
        }  
    }  

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan
Telerik team
answered on 22 May 2009, 03:59 PM
Hi David,

The reason that "nothing happens" is because of double Auto for grid rows' height - if you set all rows height with Auto for a vertically stretched grid then the last height will be actually treated as initialized with the asterisk instead.

About the code-behind: there is no need to collapse the expander content. The expander will collapse and visualize it automatically.

Attached you can find an example having your code multiplied four times in order to demonstrate different settings for grid rows height. Please note the following:
  • some margins and backgrounds are changed to emphasis the layout;
  • at the very top row there is information about the height of grid-rows;
  • in the third example (column) there is an additional MinHeight & MaxHeight for the first grid row;
  • Grid's ShowGridLines is set to True to visualize the layout.

Please give a try and let me know if additional assistance is needed.

Sincerely yours,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
David
Top achievements
Rank 2
answered on 22 May 2009, 04:48 PM
Ivan,

Thanks for not only answering my question but taking the time to provide an example with all of the options. 

David
Tags
Expander
Asked by
David
Top achievements
Rank 2
Answers by
Ivan
Telerik team
David
Top achievements
Rank 2
Share this question
or