ARTICLE

Expander control in WPF using VB.NET

Posted by Rohatash Kumar Articles | WPF using VB.NET January 03, 2011
In this article we will learn how to use Expander control in WPF.
 
Reader Level:

In this article we will learn how to use Expander control in WPF.

Expander control

An Expander control provides a way to provide content in an expandable area that resembles a window and includes a header.

Properties - This control has the following property.

e1.gif

Figure 1.

Here are few snapshots of this control.

e2.gif

Figure 2.

XAML code

The following XAML code creates the Expander control at design.

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="350" Width="525">

    <Grid Height="320">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="374*" />

            <ColumnDefinition Width="129*" />

        </Grid.ColumnDefinitions>

        <Expander Width="352" HorizontalContentAlignment="Stretch" Margin="0,0,22,187" ExpandDirection="Down" FlowDirection="LeftToRight" BorderThickness="4" HorizontalAlignment="Right" Background="Brown" Name="Expander1">

            <Expander.Header>

                <BulletDecorator>

                    <BulletDecorator.Bullet>

                        <Image Width="10" Source="images\icon.jpg"/>

                    </BulletDecorator.Bullet>

                    <TextBlock Margin="20,0,0,0" Width="87">My Expander</TextBlock>

                </BulletDecorator>

            </Expander.Header>

            <Expander.Content>

                <ScrollViewer Height="50">

                    <TextBlock TextWrapping="Wrap">

                Lorem ipsum dolor sit amet, consectetur adipisicing elit,

                sed do eiusmod tempor incididunt ut labore et dolore magna

                aliqua. Ut enim ad minim veniam, quis nostrud exercitation

                ullamco laboris nisi ut aliquip ex ea commodo consequat.

                Duis aute irure dolor in reprehenderit in voluptate velit

                esse cillum dolore eu fugiat nulla pariatur. Excepteur sint

                occaecat cupidatat non proident, sunt in culpa qui officia

                deserunt mollit anim id est laborum.

                    </TextBlock>

                </ScrollViewer>

            </Expander.Content>

        </Expander>

         </Grid>

</Window>

 

Now run the application and test it.

e3.gif

Figure 3.


Now click on the expander control. This looks like this.

e4.gif

Figure 4.

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Team Foundation Server Hosting
Become a Sponsor