Click here to Skip to main content
15,886,067 members
Articles / Programming Languages / C#

Grid960 Layout for Silverlight

Rate me:
Please Sign up or sign in to vote.
4.94/5 (13 votes)
11 Jun 2013CPOL3 min read 45.3K   1.4K   37  
The 960 Grid System is a hugely popular layout system for web sites - Grid960 lets you use it in Silverlight!
<UserControl x:Class="Grid960Sample.Grid960View"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:g960="clr-namespace:Grid960;assembly=Grid960"
             
             
    mc:Ignorable="d" FontFamily="Trebuchet MS"
    d:DesignHeight="600" d:DesignWidth="1024">

    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <GradientStop Color="#112233" Offset="0" />
                <GradientStop Color="#1a3148" Offset="1" />
            </LinearGradientBrush>
        </Grid.Background>
        
        <!-- Create a Grid960... -->
        <g960:Grid960>
                        
            <!-- First row, header and info. -->
            <g960:Grid960Row Height="180">

                <g960:Grid960Element ColumnSpan="12" VerticalAlignment="Center">
                    <TextBlock Foreground="White" FontSize="100" Text="Grid960"
                               HorizontalAlignment="Center"  />
                </g960:Grid960Element>
            </g960:Grid960Row>


            <!-- First row, header and info. -->
            <g960:Grid960Row>
                <g960:Grid960Element ColumnSpan="12" VerticalAlignment="Center" Margin="0,10">
                    <TextBlock FontSize="24" FontStyle="Italic" HorizontalAlignment="Center" TextWrapping="Wrap" Foreground="White">
                        Grid960 is a port of the excellent 960gs developed by Nathan Smith.
                    </TextBlock>
                </g960:Grid960Element>
            </g960:Grid960Row>
            
            <g960:Grid960Row>
                <g960:Grid960Element ColumnSpan="6">
                    <StackPanel Orientation="Vertical">
                        <TextBlock Foreground="White" FontSize="24" Margin="0,10" FontWeight="Bold">Step 1</TextBlock>
                        <TextBlock Foreground="White" TextWrapping="Wrap" FontSize="15" LineHeight="24">Add the Grid960 namespace:</TextBlock>
                        <Image Source="/Grid960Sample;component/Images/Namespace.png" Margin="30" />
                        <TextBlock Foreground="White" TextWrapping="Wrap" FontSize="15" LineHeight="24">Plan your layout, sketch it out and then...</TextBlock>
                    </StackPanel>
                </g960:Grid960Element>
                <g960:Grid960Element ColumnSpan="6">
                    <StackPanel Orientation="Vertical">
                        <TextBlock Foreground="White" FontSize="24" Margin="0,10" FontWeight="Bold">Step 2</TextBlock>
                        <TextBlock Foreground="White" TextWrapping="Wrap" FontSize="15" LineHeight="24">Add your Grid, Rows and Elements!</TextBlock>
                        <Image Source="/Grid960Sample;component/Images/Markup.png" Margin="30" />
                    </StackPanel>
                </g960:Grid960Element>
            </g960:Grid960Row>
            
            <g960:Grid960Row Margin="0,10,0,10">
                <g960:Grid960Element ColumnSpan="4" FontFamily="Trebuchet MS" FontSize="15">
                    <StackPanel Orientation="Vertical">
                        <TextBlock Foreground="White" FontSize="24" Margin="0,10" FontWeight="Bold">Essence</TextBlock>
                        <TextBlock Foreground="White" TextWrapping="Wrap" LineHeight="24">The 960 Grid System is an effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.</TextBlock>
                    </StackPanel>
                </g960:Grid960Element>
                <g960:Grid960Element ColumnSpan="4" FontFamily="Trebuchet MS" FontSize="15">
                    <StackPanel Orientation="Vertical">
                        <TextBlock Foreground="White" FontSize="24" Margin="0,10" FontWeight="Bold">Dimensions</TextBlock>
                        <TextBlock Foreground="White" TextWrapping="Wrap" LineHeight="24">The 12-column grid is divided into portions that are 60 pixels wide. The 16-column grid consists of 40 pixel increments. Each column has 10 pixels of margin on the left and right, which create 20 pixel wide gutters between columns.</TextBlock>
                    </StackPanel>
                </g960:Grid960Element>
                <g960:Grid960Element ColumnSpan="4" FontFamily="Trebuchet MS" FontSize="15">
                    <StackPanel Orientation="Vertical">
                        <TextBlock Foreground="White" FontSize="24" Margin="0,10" FontWeight="Bold">Purpose</TextBlock>
                        <TextBlock Foreground="White" TextWrapping="Wrap" LineHeight="24">The premise of the system is ideally suited to rapid prototyping, but it would work equally well when integrated into a production environment.</TextBlock>
                    </StackPanel>
                </g960:Grid960Element>
            </g960:Grid960Row>
            
            
        </g960:Grid960>
    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions