Question

I am creating a Windows application (WPF) and C#. In my view, I have to add few layouts like browsing a folder, displaying the files in the folder in a list view...etc

My requirement is : The panels mentioned above should be collapsible panels, I guess, we dont have option of collapsible panel in wpf.

I have to create a custom control for this? If so, Please suggest me how to do this?

Was it helpful?

Solution

The Expander control may be what you are looking for. From MSDN:

Expander Class

Represents the control that displays a header that has a collapsible window that displays content.

OTHER TIPS

May like this?

 <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="auto"/>
        <RowDefinition Height="2*"/>
    </Grid.RowDefinitions>
    <Border  Background="Red" Height="12" VerticalAlignment="Top" MouseEnter="StackPanel_MouseEnter" MouseLeave="StackPanel_MouseLeave"></Border>
</Grid>    

C# code behind

 private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
    {
        Border sp = sender as Border;
        DoubleAnimation db = new DoubleAnimation();
        //db.From = 12;
        db.To = 150;
        db.Duration = TimeSpan.FromSeconds(0.5);
        db.AutoReverse = false;
        db.RepeatBehavior = new RepeatBehavior(1);
        sp.BeginAnimation(StackPanel.HeightProperty, db);
    }

    private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
    {
        Border sp = sender as Border;
        DoubleAnimation db = new DoubleAnimation();
        //db.From = 12;
        db.To = 12;
        db.Duration = TimeSpan.FromSeconds(0.5);
        db.AutoReverse = false;
        db.RepeatBehavior = new RepeatBehavior(1);
        sp.BeginAnimation(StackPanel.HeightProperty, db);
    }
}

You can use any element control like grid, stack, dock, border ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top