Ask a questionAsk a question
 

General DiscussionAnimation to cover one control with another!

  • Saturday, November 07, 2009 4:50 AMZest4Quest Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,
     I will have a control displayed in a grid taking all the space available...and when the user clicks on this control i want another control to rise from the bottom(height from 0 to max?) and cover the available space just like the first control...
    How can i achieve this without the second control growing more than the available space also resizing everytime the main window size changes?
    Please find what i tried below..and notice what happens when you maximize and also when you restore it...
    Also when i use the "Height" instead of "ActualHeight" even this does not work...
    Thanks in advance..

    <Window x:Class="ScaleTfm.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.Triggers>
                <EventTrigger SourceName="txt1" RoutedEvent="Label.MouseDown">
                    <EventTrigger.Actions>
                        <BeginStoryboard >
                            <Storyboard >
                                <DoubleAnimation Storyboard.TargetName="txt2" Storyboard.TargetProperty="Height" To="{Binding ElementName=txt1,Path=ActualHeight}" Duration="0:0:1"></DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Grid.Triggers>
            <Label Background="Green"  Grid.Row="0" Name="txt1" Height="Auto" ></Label>
            <ListBox Background="Red" Height="0" Grid.Row="1" Name="txt2" VerticalAlignment="Bottom">
                <ListBoxItem >aaaaa</ListBoxItem>
                <ListBoxItem >bbbbbbb</ListBoxItem>
                <ListBoxItem >cccccc</ListBoxItem>
                <ListBoxItem >dddddd</ListBoxItem>
                <ListBoxItem >eeeee</ListBoxItem>
                <ListBoxItem >fffffff</ListBoxItem>
                <ListBoxItem >gggggg</ListBoxItem>
                <ListBoxItem >hhhhhh</ListBoxItem>
                <ListBoxItem >iiiiii</ListBoxItem>
                <ListBoxItem >jjjjjj</ListBoxItem>
                <ListBoxItem >kkkkkk</ListBoxItem>
                <ListBoxItem >llllll</ListBoxItem>
                <ListBoxItem >mmmmmm</ListBoxItem>
                <ListBoxItem >nnnnnn</ListBoxItem>        
                <ListBoxItem >ooooo</ListBoxItem>
                <ListBoxItem >ppppppp</ListBoxItem>
                <ListBoxItem >qqqqqqq</ListBoxItem>
                <ListBoxItem >ZZZZZZ</ListBoxItem>
            </ListBox>
           
        </Grid>
    </Window>

All Replies

  • Tuesday, November 17, 2009 10:48 AMJim Zhou - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Zest4Quest,
    -->How can i achieve this without the second control growing more than the available space also resizing everytime the main window size changes?


    Have you tried the AncestorType binding syntax? you walk up the visual tree till the type you want to access. since it's a little late in our time zoon, I will see to it tomorrow in more details.

    Thanks.
    Sincerely.
    Jim Zhou -MSFT
  • Wednesday, November 18, 2009 9:50 AMJim Zhou - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Zest4Quest,

    -->and cover the available space just like the first control...How can i achieve this without the second control growing more than the available space also resizing everytime the main window size changes?

    I ran the code you provided above, and it seemed that the ListBox can occupied all the available space the TextBlock once had, so could you please elaborate on this?

    Thanks.
    Sincerely.

    Jim Zhou -MSFT
  • Friday, November 20, 2009 8:30 AMJim Zhou - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to "Question” by clicking the "Options" link at the top of your post, and selecting "Change Type" menu item from the pop menu. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
     
    Thank you!

    Jim Zhou -MSFT