Skip to main content

Microsoft® Surface® Live Stream Code Sample

ive Stream enables businesses to engage their customers face-to-face using the most recent and relevant Twitter™, Flickr®, and RSS newsfeeds.

C# (5.9 MB)
 
 
 
 
 
4.3 Star
(4)
6,673 times
Add to favorites
4/19/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
using System.ComponentModel;
using System.Windows;
using Microsoft.Surface.Presentation.Controls;

namespace LiveStream.Controls
{
    /// <summary>
    /// Interaction logic for AdminIndicatorLight.xaml
    /// </summary>
    public partial class AdminIndicatorLight : SurfaceUserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AdminIndicatorLight"/> class.
        /// </summary>
        public AdminIndicatorLight()
        {
            InitializeComponent();

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            UpdateIsOn();
        }

        #region IsOn

        /// <summary>
        /// Gets or sets a value indicating whether this instance is on.
        /// </summary>
        /// <value><c>true</c> if this instance is on; otherwise, <c>false</c>.</value>
        public bool IsOn
        {
            get { return (bool)GetValue(IsOnProperty); }
            set { SetValue(IsOnProperty, value); }
        }

        /// <summary>
        /// Identifies the IsOn dependency property.
        /// </summary>
        public static readonly DependencyProperty IsOnProperty = DependencyProperty.Register("IsOn", typeof(bool), typeof(AdminIndicatorLight), new PropertyMetadata(false, (sender, e) => (sender as AdminIndicatorLight).UpdateIsOn()));

        /// <summary>
        /// Updates the visual state when IsOn changes.
        /// </summary>
        private void UpdateIsOn()
        {
            VisualStateManager.GoToState(this, IsOn ? OnState.Name : OffState.Name, true);
        }

        #endregion
    }
}