Click here to Skip to main content
15,891,629 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.4K   1.4K   37  
The 960 Grid System is a hugely popular layout system for web sites - Grid960 lets you use it in Silverlight!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Grid960Sample
{
    public partial class ElementView : UserControl
    {
        public ElementView()
        {
            InitializeComponent();
        }

        private void border_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            MeasuredWidth = border.ActualWidth;
        }       

        /// <summary>
        /// The DependencyProperty for the MeasuredWidth property.
        /// </summary>
        private static readonly DependencyProperty MeasuredWidthProperty =
          DependencyProperty.Register("MeasuredWidth", typeof(double), typeof(ElementView),
          new PropertyMetadata(0.0, new PropertyChangedCallback(OnMeasuredWidthChanged)));

        /// <summary>
        /// Gets or sets MeasuredWidth.
        /// </summary>
        /// <value>The value of MeasuredWidth.</value>
        public double MeasuredWidth
        {
            get { return (double)GetValue(MeasuredWidthProperty); }
            set { SetValue(MeasuredWidthProperty, value); }
        }

        /// <summary>
        /// Called when MeasuredWidth is changed.
        /// </summary>
        /// <param name="o">The o.</param>
        /// <param name="args">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnMeasuredWidthChanged(DependencyObject o, DependencyPropertyChangedEventArgs args)
        {
            ElementView me = o as ElementView;
        }
    }
}

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