AcornPublishing_wpf/9780735619579-master/AppsCodeMarkup/Chapter 08/SetSpaceProperty/SpaceWindow.cs
//--------------------------------------------
// SpaceWindow.cs (c) 2006 by Charles Petzold
//--------------------------------------------
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace Petzold.SetSpaceProperty
{
    public class SpaceWindow : Window
    {
        // DependencyProperty and property.
        public static readonly DependencyProperty SpaceProperty;

        public int Space
        {
            set
            {
                SetValue(SpaceProperty, value);
            }
            get
            {
                return (int)GetValue(SpaceProperty);
            }
        }

        // Static constructor.
        static SpaceWindow()
        {
            // Define metadata.
            FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata();
            metadata.Inherits = true;

            // Add owner to SpaceProperty and override metadata.
            SpaceProperty = 
                SpaceButton.SpaceProperty.AddOwner(typeof(SpaceWindow));
            SpaceProperty.OverrideMetadata(typeof(SpaceWindow), metadata);
        }
    }
}
