Expander layout issue

3 posts, 1 answers
  1. Murray
    Murray avatar
    121 posts
    Member since:
    Aug 2010

    Posted 12 Dec 2011 Link to this post

    I need two expanders in a grid but I need the bottom expander to fill the available space. I can do this by letting the height go to Stretch, but then when I collapse the expander the content animates towards the middle not the top as expected.
    Any idea how to have both expanders collapse upward, have the content collapse upward, yet have the content fill the screen when expanded?

    <UserControl
        x:Class="SilverlightApplication6.MainPage"
        d:DesignWidth="1024" d:DesignHeight="768"
        >
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <telerik:RadExpander Header="Header" VerticalAlignment="Top" IsExpanded="True">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Rectangle Height="100" Fill="Red"/>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Row="1">
                        <telerik:RadButton Content="Button1"/>
                        <telerik:RadButton Content="Button2"/>
                    </StackPanel>
                </Grid>
            </telerik:RadExpander>
            <telerik:RadExpander Header="Header" IsExpanded="True" Grid.Row="1">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <telerik:RadGridView/>
                    <telerik:RadDataPager Grid.Row="1"/>
                </Grid>
            </telerik:RadExpander>
        </Grid>
    </UserControl>

    Any help would be awesome!

  2. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 12 Dec 2011 Link to this post

    Hi Murray,

     What you need is not possible using the default expander animation. But you can change the default application with new one, so that it betters suits your needs.
    I've created an example animation that works for your case. (You can find it attached)
    Also you can change it that way.

    <telerik:RadExpander Header="Header" IsExpanded="True"
                    Grid.Row="1">
                <telerik:AnimationManager.AnimationSelector>
                    <telerik:AnimationSelector>
                        <local:ExpanderExpandCollapseAnimation AnimationName="Expand" Direction="In"
                                TargetElementName="Content" />
                        <local:ExpanderExpandCollapseAnimation AnimationName="Collapse" Direction="Out"
                                TargetElementName="Content" />
                    </telerik:AnimationSelector>
                </telerik:AnimationManager.AnimationSelector>
                <Rectangle Fill="Blue" />
            </telerik:RadExpander>

    Here is how to use it. 
    You scenario is also kind of common, so we decided to also fix this and provide out-of-the-box way of doing it, so it will be fixed and available soon.
    Sorry for any inconvenience. 

    Best wishes,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Murray
    Murray avatar
    121 posts
    Member since:
    Aug 2010

    Posted 13 Dec 2011 Link to this post

    Thank you Miro for the workaround! This will do the job for now and I look forward to seeing this fix in an upcoming build.

    Murray
Back to Top