SIGN UP MEMBER LOGIN:    
ARTICLE

Grid Splitter In Silverlight 3 Using Blend 3

Posted by Diptimaya Patra Articles | XAML August 03, 2009
This article discusses how to use a Grid Splitter control in Silverlight 3 using Expression Blend 3.
Reader Level:
Download Files:
 

Crating Silverlight Project

Fire up Expression Blend 3 and create a Silverlight Application. Name it as GridSplitterInSL3.

GSImg1.gif

Go ahead and design your application. In our sample I have designed the following.

GSImg2.gif

I have changed the LayoutRoot as Stack Panel and then I have added a Grid. Inside the Grid it is divided into two columns and each column will contain a Grid.

And the inside Grid is I have placed four Buttons in respective cells.

Follow the XAML code:

<StackPanel>

        <Grid>

            <Grid.ColumnDefinitions>

                <ColumnDefinition Width="*" />

                <ColumnDefinition Width="*" />

            </Grid.ColumnDefinitions>

           

            <Grid Grid.Row="1" Grid.Column="0">

                <Grid.ColumnDefinitions>

                    <ColumnDefinition Width="100" />

                    <ColumnDefinition Width="5" />

                    <ColumnDefinition Width="100" />

                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>

                    <RowDefinition Height="100" />

                    <RowDefinition Height="5" />

                    <RowDefinition Height="100" />

                </Grid.RowDefinitions>

               

                <Button Margin="0" Content="Button" Background="Red"/>

                <Button Grid.Column="2" Content="Button" d:LayoutOverrides="Height" Background="Blue"/>

                <Button Margin="0" Grid.Row="2" Content="Button" Background="Yellow"/>

                <Button Grid.Column="2" Grid.Row="2" Content="Button" d:LayoutOverrides="Height" Background="Lime"/>

            </Grid>

           

            <Grid Grid.Row="1" Grid.Column="2">

                <Grid.ColumnDefinitions>

                    <ColumnDefinition Width="100" />

                    <ColumnDefinition Width="5" />

                    <ColumnDefinition Width="100" />

                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>

                    <RowDefinition Height="100" />

                    <RowDefinition Height="5" />

                    <RowDefinition Height="100" />

                </Grid.RowDefinitions>

                <Button Margin="0" Background="Red" Content="Button"/>

                <Button Background="Blue" Grid.Column="2" Content="Button" d:LayoutOverrides="Height"/>

                <Button Margin="0" Background="Yellow" Grid.Row="2" Content="Button"/>

                <Button Background="Lime" Grid.Column="2" Grid.Row="2" Content="Button" d:LayoutOverrides="Height"/>

               

            </Grid>

        </Grid>

    </StackPanel>

Our main objective is to use Grid Splitter. So go ahead and search Grid Splitter in Asset Library.

GSImg3.gif

Now add two Grid Splitters each for the Grids.

And modify the Following Properties.

<controls:GridSplitter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

<controls:GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

The next set of Grid Splitters will have a property called ShowPreview. The default value is false. So we will make it True.

<controls:GridSplitter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowsPreview="True" />

<controls:GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ShowsPreview="True" />

Now go ahead and run your application.

You will see the cursor change when you mouse hover the Grid Splitter.

The basic difference between ShowPreview values True and False is when it is set true the preview of resizing is true.

GSImg4.gif

That's it you have successfully used Grid Splitter. Play with it more to know more.

Enjoy Coding.

share this article :
post comment
 
Team Foundation Server Hosting
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.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor