Recover Space

3 posts, 1 answers
  1. David
    David avatar
    4 posts
    Member since:
    May 2009

    Posted 21 May 2009 Link to this post

    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" 
            Title="Test" Height="350" Width="250" Background="Beige">  
                <RowDefinition Height="Auto" /> 
                <RowDefinition Height="Auto" /> 
            <Image Grid.Row="0" 
                   Stretch="Uniform" MaxHeight="250" /> 
            <telerik:RadExpander x:Name="radExpander"   
                                 VerticalAlignment="Stretch" HorizontalAlignment="Stretch"   
                                 Collapsed="radExpander_Collapsed" Expanded="radExpander_Expanded">  
                    <TextBlock x:Name="expanderCaption" Foreground="#FFFFFFFF" Text="Test Box" 
                                Visibility="Visible" /> 
                    <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" /> 





    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()  
            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. Answer
    Ivan avatar
    519 posts

    Posted 22 May 2009 Link to this post

    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,
    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.
  3. David
    David avatar
    4 posts
    Member since:
    May 2009

    Posted 22 May 2009 Link to this post


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

Back to Top