DataGridColumnDropSeparator.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / DataGridColumnDropSeparator.cs / 1305600 / DataGridColumnDropSeparator.cs

                            //---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
//--------------------------------------------------------------------------- 

using System; 
using System.Windows; 
using System.Windows.Controls.Primitives;
 
using MS.Internal;

namespace System.Windows.Controls
{ 
    /// 
    /// The separator used to indicate drop location during column header drag-drop 
    ///  
    internal class DataGridColumnDropSeparator : Separator
    { 
        #region Constructors

        static DataGridColumnDropSeparator()
        { 
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(DataGridColumnDropSeparator), 
                new FrameworkPropertyMetadata(DataGridColumnHeader.ColumnHeaderDropSeparatorStyleKey)); 

            WidthProperty.OverrideMetadata( 
                typeof(DataGridColumnDropSeparator),
                new FrameworkPropertyMetadata(null, new CoerceValueCallback(OnCoerceWidth)));

            HeightProperty.OverrideMetadata( 
                typeof(DataGridColumnDropSeparator),
                new FrameworkPropertyMetadata(null, new CoerceValueCallback(OnCoerceHeight))); 
        } 

        #endregion 

        #region Static Methods

        private static object OnCoerceWidth(DependencyObject d, object baseValue) 
        {
            double width = (double)baseValue; 
            if (DoubleUtil.IsNaN(width)) 
            {
                return 2.0; 
            }

            return baseValue;
        } 

        private static object OnCoerceHeight(DependencyObject d, object baseValue) 
        { 
            double height = (double)baseValue;
            DataGridColumnDropSeparator separator = (DataGridColumnDropSeparator)d; 
            if (separator._referenceHeader != null && DoubleUtil.IsNaN(height))
            {
                return separator._referenceHeader.ActualHeight;
            } 

            return baseValue; 
        } 

        #endregion 

        #region Properties

        internal DataGridColumnHeader ReferenceHeader 
        {
            get 
            { 
                return _referenceHeader;
            } 

            set
            {
                _referenceHeader = value; 
            }
        } 
 
        #endregion
 
        #region Data

        private DataGridColumnHeader _referenceHeader;
 
        #endregion
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
//--------------------------------------------------------------------------- 

using System; 
using System.Windows; 
using System.Windows.Controls.Primitives;
 
using MS.Internal;

namespace System.Windows.Controls
{ 
    /// 
    /// The separator used to indicate drop location during column header drag-drop 
    ///  
    internal class DataGridColumnDropSeparator : Separator
    { 
        #region Constructors

        static DataGridColumnDropSeparator()
        { 
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(DataGridColumnDropSeparator), 
                new FrameworkPropertyMetadata(DataGridColumnHeader.ColumnHeaderDropSeparatorStyleKey)); 

            WidthProperty.OverrideMetadata( 
                typeof(DataGridColumnDropSeparator),
                new FrameworkPropertyMetadata(null, new CoerceValueCallback(OnCoerceWidth)));

            HeightProperty.OverrideMetadata( 
                typeof(DataGridColumnDropSeparator),
                new FrameworkPropertyMetadata(null, new CoerceValueCallback(OnCoerceHeight))); 
        } 

        #endregion 

        #region Static Methods

        private static object OnCoerceWidth(DependencyObject d, object baseValue) 
        {
            double width = (double)baseValue; 
            if (DoubleUtil.IsNaN(width)) 
            {
                return 2.0; 
            }

            return baseValue;
        } 

        private static object OnCoerceHeight(DependencyObject d, object baseValue) 
        { 
            double height = (double)baseValue;
            DataGridColumnDropSeparator separator = (DataGridColumnDropSeparator)d; 
            if (separator._referenceHeader != null && DoubleUtil.IsNaN(height))
            {
                return separator._referenceHeader.ActualHeight;
            } 

            return baseValue; 
        } 

        #endregion 

        #region Properties

        internal DataGridColumnHeader ReferenceHeader 
        {
            get 
            { 
                return _referenceHeader;
            } 

            set
            {
                _referenceHeader = value; 
            }
        } 
 
        #endregion
 
        #region Data

        private DataGridColumnHeader _referenceHeader;
 
        #endregion
    } 
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK