DataTemplate,Describes the visual structure of a data object.
ControlTemplate,Specifies the visual structure and behavioral aspects of a System.Windows.Controls.Control that can be shared across multiple instances of the control.
//DataTemplate #region Assembly PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // location unknown // Decompiled with ICSharpCode.Decompiler 8.1.1.7464 #endregion using System.ComponentModel; using System.Windows.Controls; using System.Windows.Markup; namespace System.Windows; // // Summary: // Describes the visual structure of a data object. [DictionaryKeyProperty("DataTemplateKey")] public class DataTemplate : FrameworkTemplate { private object _dataType; private TriggerCollection _triggers; // // Summary: // Gets or sets the type for which this System.Windows.DataTemplate is intended. // // // Returns: // The default value is null. [DefaultValue(null)] [Ambient] public object DataType { get { return _dataType; } set { Exception ex = TemplateKey.ValidateDataType(value, "value"); if (ex != null) { throw ex; } CheckSealed(); _dataType = value; } } // // Summary: // Gets a collection of triggers that apply property values or perform actions based // on one or more conditions. // // Returns: // A collection of trigger objects. The default value is null. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [DependsOn("VisualTree")] [DependsOn("Template")] public TriggerCollection Triggers { get { if (_triggers == null) { _triggers = new TriggerCollection(); if (base.IsSealed) { _triggers.Seal(); } } return _triggers; } } // // Summary: // Gets the default key of the System.Windows.DataTemplate. // // Returns: // The default key of the System.Windows.DataTemplate. public object DataTemplateKey { get { if (DataType == null) { return null; } return new DataTemplateKey(DataType); } } internal override Type TargetTypeInternal => DefaultTargetType; internal override object DataTypeInternal => DataType; internal override TriggerCollection TriggersInternal => Triggers; internal static Type DefaultTargetType => typeof(ContentPresenter); // // Summary: // Initializes a new instance of the System.Windows.DataTemplate class. public DataTemplate() { } // // Summary: // Initializes a new instance of the System.Windows.DataTemplate class with the // specified System.Windows.DataTemplate.DataType property. // // Parameters: // dataType: // If the template is intended for object data, this is the Type name of the data // object. public DataTemplate(object dataType) { Exception ex = TemplateKey.ValidateDataType(dataType, "dataType"); if (ex != null) { throw ex; } _dataType = dataType; } internal override void SetTargetTypeInternal(Type targetType) { throw new InvalidOperationException(SR.Get("TemplateNotTargetType")); } // // Summary: // Checks the templated parent against a set of rules. // // Parameters: // templatedParent: // The element this template is applied to. protected override void ValidateTemplatedParent(FrameworkElement templatedParent) { if (templatedParent == null) { throw new ArgumentNullException("templatedParent"); } if (!(templatedParent is ContentPresenter)) { throw new ArgumentException(SR.Get("TemplateTargetTypeMismatch", "ContentPresenter", templatedParent.GetType().Name)); } } } #if false // Decompilation log '15' items in cache ------------------ Resolve: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\mscorlib.dll' ------------------ Resolve: 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xaml.dll' ------------------ Resolve: 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Found single assembly: 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\WindowsBase.dll' ------------------ Resolve: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll' ------------------ Resolve: 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Found single assembly: 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\PresentationCore.dll' ------------------ Resolve: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ------------------ Resolve: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xml.dll' ------------------ Resolve: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Core.dll' ------------------ Resolve: 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ------------------ Resolve: 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' #endif
//ControlTemplate #region Assembly PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // location unknown // Decompiled with ICSharpCode.Decompiler 8.1.1.7464 #endregion using System.ComponentModel; using System.Windows.Markup; using System.Windows.Navigation; namespace System.Windows.Controls; // // Summary: // Specifies the visual structure and behavioral aspects of a System.Windows.Controls.Control // that can be shared across multiple instances of the control. [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] [DictionaryKeyProperty("TargetType")] public class ControlTemplate : FrameworkTemplate { private Type _targetType; private TriggerCollection _triggers; internal static readonly Type DefaultTargetType = typeof(Control); // // Summary: // Gets or sets the type for which this System.Windows.Controls.ControlTemplate // is intended. // // Returns: // The default value is null. // // Exceptions: // T:System.ArgumentNullException: // The System.Windows.Controls.ControlTemplate.TargetType property must not be null // if the definition of the template has a System.Windows.Controls.ContentPresenter. // // // T:System.ArgumentException: // The specified types are not valid. The System.Windows.Controls.ControlTemplate.TargetType // of a System.Windows.Controls.ControlTemplate must be or inherit from a System.Windows.Controls.Control, // a System.Windows.Controls.Page, or a System.Windows.Navigation.PageFunctionBase. [Ambient] [DefaultValue(null)] public Type TargetType { get { return _targetType; } set { ValidateTargetType(value, "value"); CheckSealed(); _targetType = value; } } // // Summary: // Gets a collection of System.Windows.TriggerBase objects that apply property changes // or perform actions based on specified conditions. // // Returns: // A collection of System.Windows.TriggerBase objects. The default value is null. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [DependsOn("VisualTree")] [DependsOn("Template")] public TriggerCollection Triggers { get { if (_triggers == null) { _triggers = new TriggerCollection(); if (base.IsSealed) { _triggers.Seal(); } } return _triggers; } } internal override Type TargetTypeInternal { get { if (TargetType != null) { return TargetType; } return DefaultTargetType; } } internal override TriggerCollection TriggersInternal => Triggers; // // Summary: // Initializes a new instance of the System.Windows.Controls.ControlTemplate class. public ControlTemplate() { } // // Summary: // Initializes a new instance of the System.Windows.Controls.ControlTemplate class // with the specified target type. // // Parameters: // targetType: // The type this template is intended for. public ControlTemplate(Type targetType) { ValidateTargetType(targetType, "targetType"); _targetType = targetType; } // // Summary: // Checks the templated parent against a set of rules. // // Parameters: // templatedParent: // The element this template is applied to. // // Exceptions: // T:System.ArgumentNullException: // The templatedParent must not be null. // // T:System.ArgumentException: // The System.Windows.Controls.ControlTemplate.TargetType of a System.Windows.Controls.ControlTemplate // must match the type of the System.Windows.Controls.Control that it is being applied // to. // // T:System.ArgumentException: // You must associate the System.Windows.Controls.ControlTemplate with a System.Windows.Controls.Control // by setting the System.Windows.Controls.Control.Template property before using // the System.Windows.Controls.ControlTemplate on the System.Windows.Controls.Control. protected override void ValidateTemplatedParent(FrameworkElement templatedParent) { if (templatedParent == null) { throw new ArgumentNullException("templatedParent"); } if (_targetType != null && !_targetType.IsInstanceOfType(templatedParent)) { throw new ArgumentException(SR.Get("TemplateTargetTypeMismatch", _targetType.Name, templatedParent.GetType().Name)); } if (templatedParent.TemplateInternal != this) { throw new ArgumentException(SR.Get("MustNotTemplateUnassociatedControl")); } } private void ValidateTargetType(Type targetType, string argName) { if (targetType == null) { throw new ArgumentNullException(argName); } if (!typeof(Control).IsAssignableFrom(targetType) && !typeof(Page).IsAssignableFrom(targetType) && !typeof(PageFunctionBase).IsAssignableFrom(targetType)) { throw new ArgumentException(SR.Get("InvalidControlTemplateTargetType", targetType.Name)); } } internal override void SetTargetTypeInternal(Type targetType) { TargetType = targetType; } } #if false // Decompilation log '15' items in cache ------------------ Resolve: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\mscorlib.dll' ------------------ Resolve: 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xaml.dll' ------------------ Resolve: 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Found single assembly: 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\WindowsBase.dll' ------------------ Resolve: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll' ------------------ Resolve: 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Found single assembly: 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\PresentationCore.dll' ------------------ Resolve: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ------------------ Resolve: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xml.dll' ------------------ Resolve: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Core.dll' ------------------ Resolve: 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ------------------ Resolve: 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' #endif
#region Assembly PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 // location unknown // Decompiled with ICSharpCode.Decompiler 8.1.1.7464 #endregion using System.ComponentModel; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; using MS.Internal.KnownBoxes; using MS.Internal.PresentationFramework; using MS.Utility; namespace System.Windows.Controls; // // Summary: // Represents the base class for user interface (UI) elements that use a System.Windows.Controls.ControlTemplate // to define their appearance. public class Control : FrameworkElement { internal enum ControlBoolFlags : ushort { ContentIsNotLogical = 1, IsSpaceKeyDown = 2, HeaderIsNotLogical = 4, CommandDisabled = 8, ContentIsItem = 0x10, HeaderIsItem = 0x20, ScrollHostValid = 0x40, ContainsSelection = 0x80, VisualStateChangeSuspended = 0x100 } // // Summary: // Identifies the System.Windows.Controls.Control.BorderBrush dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.BorderBrush dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty BorderBrushProperty; // // Summary: // Identifies the System.Windows.Controls.Control.BorderThickness dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.BorderThickness dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty BorderThicknessProperty; // // Summary: // Identifies the System.Windows.Controls.Control.Background dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.Background dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty BackgroundProperty; // // Summary: // Identifies the System.Windows.Controls.Control.Foreground dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.Foreground dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty ForegroundProperty; // // Summary: // Identifies the System.Windows.Controls.Control.FontFamily dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.FontFamily dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty FontFamilyProperty; // // Summary: // Identifies the System.Windows.Controls.Control.FontSize dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.FontSize dependency property. [CommonDependencyProperty] public static readonly DependencyProperty FontSizeProperty; // // Summary: // Identifies the System.Windows.Controls.Control.FontStretch dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.FontStretch dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty FontStretchProperty; // // Summary: // Identifies the System.Windows.Controls.Control.FontStyle dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.FontStyle dependency property. [CommonDependencyProperty] public static readonly DependencyProperty FontStyleProperty; // // Summary: // Identifies the System.Windows.Controls.Control.FontWeight dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.FontWeight dependency // property. [CommonDependencyProperty] public static readonly DependencyProperty FontWeightProperty; // // Summary: // Identifies the System.Windows.Controls.Control.HorizontalContentAlignment dependency // property. // // Returns: // The identifier for the System.Windows.Controls.Control.HorizontalContentAlignment // dependency property. [CommonDependencyProperty] public static readonly DependencyProperty HorizontalContentAlignmentProperty; // // Summary: // Identifies the System.Windows.Controls.Control.VerticalContentAlignment dependency // property. // // Returns: // The identifier for the System.Windows.Controls.Control.VerticalContentAlignment // dependency property. [CommonDependencyProperty] public static readonly DependencyProperty VerticalContentAlignmentProperty; // // Summary: // Identifies the System.Windows.Controls.Control.TabIndex dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.TabIndex dependency property. [CommonDependencyProperty] public static readonly DependencyProperty TabIndexProperty; // // Summary: // Identifies the System.Windows.Controls.Control.IsTabStop dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.IsTabStop dependency property. [CommonDependencyProperty] public static readonly DependencyProperty IsTabStopProperty; // // Summary: // Identifies the System.Windows.Controls.Control.Padding dependency property. // // Returns: // The identifier for the System.Windows.Controls.Control.Padding dependency property. [CommonDependencyProperty] public static readonly DependencyProperty PaddingProperty; // // Summary: // Identifies the System.Windows.Controls.Control.Template dependency property. // // // Returns: // The identifier for the System.Windows.Controls.Control.Template dependency property. [CommonDependencyProperty] public static readonly DependencyProperty TemplateProperty; // // Summary: // Identifies the System.Windows.Controls.Control.PreviewMouseDoubleClick routed // event. // // Returns: // The identifier for the System.Windows.Controls.Control.PreviewMouseDoubleClick // routed event. public static readonly RoutedEvent PreviewMouseDoubleClickEvent; // // Summary: // Identifies the System.Windows.Controls.Control.MouseDoubleClick routed event. // // // Returns: // The identifier for the System.Windows.Controls.Control.MouseDoubleClick routed // event. public static readonly RoutedEvent MouseDoubleClickEvent; private ControlTemplate _templateCache; internal ControlBoolFlags _controlBoolField; // // Summary: // Gets or sets a brush that describes the border background of a control. // // Returns: // The brush that is used to fill the control's border; the default is System.Windows.Media.Brushes.Transparent. [Bindable(true)] [Category("Appearance")] public Brush BorderBrush { get { return (Brush)GetValue(BorderBrushProperty); } set { SetValue(BorderBrushProperty, value); } } // // Summary: // Gets or sets the border thickness of a control. // // Returns: // A thickness value; the default is a thickness of 0 on all four sides. [Bindable(true)] [Category("Appearance")] public Thickness BorderThickness { get { return (Thickness)GetValue(BorderThicknessProperty); } set { SetValue(BorderThicknessProperty, value); } } // // Summary: // Gets or sets a brush that describes the background of a control. // // Returns: // The brush that is used to fill the background of the control. The default is // System.Windows.Media.Brushes.Transparent. [Bindable(true)] [Category("Appearance")] public Brush Background { get { return (Brush)GetValue(BackgroundProperty); } set { SetValue(BackgroundProperty, value); } } // // Summary: // Gets or sets a brush that describes the foreground color. // // Returns: // The brush that paints the foreground of the control. The default value is the // system dialog font color. [Bindable(true)] [Category("Appearance")] public Brush Foreground { get { return (Brush)GetValue(ForegroundProperty); } set { SetValue(ForegroundProperty, value); } } // // Summary: // Gets or sets the font family of the control. // // Returns: // A font family. The default is the system dialog font. [Bindable(true)] [Category("Appearance")] [Localizability(LocalizationCategory.Font)] public FontFamily FontFamily { get { return (FontFamily)GetValue(FontFamilyProperty); } set { SetValue(FontFamilyProperty, value); } } // // Summary: // Gets or sets the font size. // // Returns: // The size of the text in the System.Windows.Controls.Control. The default is System.Windows.SystemFonts.MessageFontSize. // The font size must be a positive number. [TypeConverter(typeof(FontSizeConverter))] [Bindable(true)] [Category("Appearance")] [Localizability(LocalizationCategory.None)] public double FontSize { get { return (double)GetValue(FontSizeProperty); } set { SetValue(FontSizeProperty, value); } } // // Summary: // Gets or sets the degree to which a font is condensed or expanded on the screen. // // // Returns: // A System.Windows.FontStretch value. The default is System.Windows.FontStretches.Normal. [Bindable(true)] [Category("Appearance")] public FontStretch FontStretch { get { return (FontStretch)GetValue(FontStretchProperty); } set { SetValue(FontStretchProperty, value); } } // // Summary: // Gets or sets the font style. // // Returns: // A System.Windows.FontStyle value. The default is System.Windows.FontStyles.Normal. [Bindable(true)] [Category("Appearance")] public FontStyle FontStyle { get { return (FontStyle)GetValue(FontStyleProperty); } set { SetValue(FontStyleProperty, value); } } // // Summary: // Gets or sets the weight or thickness of the specified font. // // Returns: // A System.Windows.FontWeight value. The default is System.Windows.FontWeights.Normal. [Bindable(true)] [Category("Appearance")] public FontWeight FontWeight { get { return (FontWeight)GetValue(FontWeightProperty); } set { SetValue(FontWeightProperty, value); } } // // Summary: // Gets or sets the horizontal alignment of the control's content. // // Returns: // One of the System.Windows.HorizontalAlignment values. The default is System.Windows.HorizontalAlignment.Left. [Bindable(true)] [Category("Layout")] public HorizontalAlignment HorizontalContentAlignment { get { return (HorizontalAlignment)GetValue(HorizontalContentAlignmentProperty); } set { SetValue(HorizontalContentAlignmentProperty, value); } } // // Summary: // Gets or sets the vertical alignment of the control's content. // // Returns: // One of the System.Windows.VerticalAlignment values. The default is System.Windows.VerticalAlignment.Top. [Bindable(true)] [Category("Layout")] public VerticalAlignment VerticalContentAlignment { get { return (VerticalAlignment)GetValue(VerticalContentAlignmentProperty); } set { SetValue(VerticalContentAlignmentProperty, value); } } // // Summary: // Gets or sets a value that determines the order in which elements receive focus // when the user navigates through controls by using the TAB key. // // Returns: // A value that determines the order of logical navigation for a device. The default // value is System.Int32.MaxValue. [Bindable(true)] [Category("Behavior")] public int TabIndex { get { return (int)GetValue(TabIndexProperty); } set { SetValue(TabIndexProperty, value); } } // // Summary: // Gets or sets a value that indicates whether a control is included in tab navigation. // // // Returns: // true if the control is included in tab navigation; otherwise, false. The default // is true. [Bindable(true)] [Category("Behavior")] public bool IsTabStop { get { return (bool)GetValue(IsTabStopProperty); } set { SetValue(IsTabStopProperty, BooleanBoxes.Box(value)); } } // // Summary: // Gets or sets the padding inside a control. // // Returns: // The amount of space between the content of a System.Windows.Controls.Control // and its System.Windows.FrameworkElement.Margin or System.Windows.Controls.Border. // The default is a thickness of 0 on all four sides. [Bindable(true)] [Category("Layout")] public Thickness Padding { get { return (Thickness)GetValue(PaddingProperty); } set { SetValue(PaddingProperty, value); } } // // Summary: // Gets or sets a control template. // // Returns: // The template that defines the appearance of the System.Windows.Controls.Control. public ControlTemplate Template { get { return _templateCache; } set { SetValue(TemplateProperty, value); } } internal override FrameworkTemplate TemplateInternal => Template; internal override FrameworkTemplate TemplateCache { get { return _templateCache; } set { _templateCache = (ControlTemplate)value; } } // // Summary: // Gets a value that indicates whether a control supports scrolling. // // Returns: // true if the control has a System.Windows.Controls.ScrollViewer in its style and // has a custom keyboard scrolling behavior; otherwise, false. protected internal virtual bool HandlesScrolling => false; internal bool VisualStateChangeSuspended { get { return ReadControlFlag(ControlBoolFlags.VisualStateChangeSuspended); } set { WriteControlFlag(ControlBoolFlags.VisualStateChangeSuspended, value); } } // // Summary: // Occurs when a user clicks the mouse button two or more times. public event MouseButtonEventHandler PreviewMouseDoubleClick { add { AddHandler(PreviewMouseDoubleClickEvent, value); } remove { RemoveHandler(PreviewMouseDoubleClickEvent, value); } } // // Summary: // Occurs when a mouse button is clicked two or more times. public event MouseButtonEventHandler MouseDoubleClick { add { AddHandler(MouseDoubleClickEvent, value); } remove { RemoveHandler(MouseDoubleClickEvent, value); } } static Control() { BorderBrushProperty = Border.BorderBrushProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(Border.BorderBrushProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.None)); BorderThicknessProperty = Border.BorderThicknessProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(Border.BorderThicknessProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.None)); BackgroundProperty = Panel.BackgroundProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(Panel.BackgroundProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.None)); ForegroundProperty = TextElement.ForegroundProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(SystemColors.ControlTextBrush, FrameworkPropertyMetadataOptions.Inherits)); FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(SystemFonts.MessageFontFamily, FrameworkPropertyMetadataOptions.Inherits)); FontSizeProperty = TextElement.FontSizeProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(SystemFonts.MessageFontSize, FrameworkPropertyMetadataOptions.Inherits)); FontStretchProperty = TextElement.FontStretchProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(TextElement.FontStretchProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.Inherits)); FontStyleProperty = TextElement.FontStyleProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(SystemFonts.MessageFontStyle, FrameworkPropertyMetadataOptions.Inherits)); FontWeightProperty = TextElement.FontWeightProperty.AddOwner(typeof(Control), new FrameworkPropertyMetadata(SystemFonts.MessageFontWeight, FrameworkPropertyMetadataOptions.Inherits)); HorizontalContentAlignmentProperty = DependencyProperty.Register("HorizontalContentAlignment", typeof(HorizontalAlignment), typeof(Control), new FrameworkPropertyMetadata(HorizontalAlignment.Left), FrameworkElement.ValidateHorizontalAlignmentValue); VerticalContentAlignmentProperty = DependencyProperty.Register("VerticalContentAlignment", typeof(VerticalAlignment), typeof(Control), new FrameworkPropertyMetadata(VerticalAlignment.Top), FrameworkElement.ValidateVerticalAlignmentValue); TabIndexProperty = KeyboardNavigation.TabIndexProperty.AddOwner(typeof(Control)); IsTabStopProperty = KeyboardNavigation.IsTabStopProperty.AddOwner(typeof(Control)); PaddingProperty = DependencyProperty.Register("Padding", typeof(Thickness), typeof(Control), new FrameworkPropertyMetadata(default(Thickness), FrameworkPropertyMetadataOptions.AffectsParentMeasure)); TemplateProperty = DependencyProperty.Register("Template", typeof(ControlTemplate), typeof(Control), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure, OnTemplateChanged)); PreviewMouseDoubleClick = EventManager.RegisterRoutedEvent("PreviewMouseDoubleClick", RoutingStrategy.Direct, typeof(MouseButtonEventHandler), typeof(Control)); MouseDoubleClick = EventManager.RegisterRoutedEvent("MouseDoubleClick", RoutingStrategy.Direct, typeof(MouseButtonEventHandler), typeof(Control)); UIElement.FocusableProperty.OverrideMetadata(typeof(Control), new FrameworkPropertyMetadata(BooleanBoxes.TrueBox)); EventManager.RegisterClassHandler(typeof(Control), UIElement.PreviewMouseLeftButtonDown, new MouseButtonEventHandler(HandleDoubleClick), handledEventsToo: true); EventManager.RegisterClassHandler(typeof(Control), UIElement.MouseLeftButtonDown, new MouseButtonEventHandler(HandleDoubleClick), handledEventsToo: true); EventManager.RegisterClassHandler(typeof(Control), UIElement.PreviewMouseRightButtonDown, new MouseButtonEventHandler(HandleDoubleClick), handledEventsToo: true); EventManager.RegisterClassHandler(typeof(Control), UIElement.MouseRightButtonDown, new MouseButtonEventHandler(HandleDoubleClick), handledEventsToo: true); UIElement.IsKeyboardFocusedPropertyKey.OverrideMetadata(typeof(Control), new PropertyMetadata(OnVisualStatePropertyChanged)); } // // Summary: // Initializes a new instance of the System.Windows.Controls.Control class. public Control() { PropertyMetadata metadata = TemplateProperty.GetMetadata(base.DependencyObjectType); ControlTemplate controlTemplate = (ControlTemplate)metadata.DefaultValue; if (controlTemplate != null) { OnTemplateChanged(this, new DependencyPropertyChangedEventArgs(TemplateProperty, metadata, null, controlTemplate)); } } private static bool IsMarginValid(object value) { Thickness thickness = (Thickness)value; if (thickness.Left >= 0.0 && thickness.Right >= 0.0 && thickness.Top >= 0.0) { return thickness.Bottom >= 0.0; } return false; } internal override void OnTemplateChangedInternal(FrameworkTemplate oldTemplate, FrameworkTemplate newTemplate) { OnTemplateChanged((ControlTemplate)oldTemplate, (ControlTemplate)newTemplate); } private static void OnTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Control fe = (Control)d; StyleHelper.UpdateTemplateCache(fe, (FrameworkTemplate)e.OldValue, (FrameworkTemplate)e.NewValue, TemplateProperty); } // // Summary: // Called whenever the control's template changes. // // Parameters: // oldTemplate: // The old template. // // newTemplate: // The new template. protected virtual void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate) { } // // Summary: // Returns the string representation of a System.Windows.Controls.Control object. // // // Returns: // A string that represents the control. public override string ToString() { string text = null; text = ((!CheckAccess()) ? ((string)base.Dispatcher.Invoke(DispatcherPriority.Send, new TimeSpan(0, 0, 0, 0, 20), (DispatcherOperationCallback)((object o) => GetPlainText()), null)) : GetPlainText()); if (!string.IsNullOrEmpty(text)) { return SR.Get("ToStringFormatString_Control", base.ToString(), text); } return base.ToString(); } // // Summary: // Raises the System.Windows.Controls.Control.PreviewMouseDoubleClick routed event. // // // Parameters: // e: // The event data. protected virtual void OnPreviewMouseDoubleClick(MouseButtonEventArgs e) { RaiseEvent(e); } // // Summary: // Raises the System.Windows.Controls.Control.MouseDoubleClick routed event. // // Parameters: // e: // The event data. protected virtual void OnMouseDoubleClick(MouseButtonEventArgs e) { RaiseEvent(e); } private static void HandleDoubleClick(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2) { Control control = (Control)sender; MouseButtonEventArgs mouseButtonEventArgs = new MouseButtonEventArgs(e.MouseDevice, e.Timestamp, e.ChangedButton, e.StylusDevice); if (e.RoutedEvent == UIElement.PreviewMouseLeftButtonDown || e.RoutedEvent == UIElement.PreviewMouseRightButtonDown) { mouseButtonEventArgs.RoutedEvent = PreviewMouseDoubleClick; mouseButtonEventArgs.Source = e.OriginalSource; mouseButtonEventArgs.OverrideSource(e.Source); control.OnPreviewMouseDoubleClick(mouseButtonEventArgs); } else { mouseButtonEventArgs.RoutedEvent = MouseDoubleClick; mouseButtonEventArgs.Source = e.OriginalSource; mouseButtonEventArgs.OverrideSource(e.Source); control.OnMouseDoubleClick(mouseButtonEventArgs); } if (mouseButtonEventArgs.Handled) { e.Handled = true; } } } internal override void OnPreApplyTemplate() { VisualStateChangeSuspended = true; base.OnPreApplyTemplate(); } internal override void OnPostApplyTemplate() { base.OnPostApplyTemplate(); VisualStateChangeSuspended = false; UpdateVisualState(useTransitions: false); } internal void UpdateVisualState() { UpdateVisualState(useTransitions: true); } internal void UpdateVisualState(bool useTransitions) { EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordGeneral | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Info, EventTrace.Event.UpdateVisualStateStart); if (!VisualStateChangeSuspended) { ChangeVisualState(useTransitions); } EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordGeneral | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Info, EventTrace.Event.UpdateVisualStateEnd); } internal virtual void ChangeVisualState(bool useTransitions) { ChangeValidationVisualState(useTransitions); } internal void ChangeValidationVisualState(bool useTransitions) { if (Validation.GetHasError(this)) { if (base.IsKeyboardFocused) { VisualStateManager.GoToState(this, "InvalidFocused", useTransitions); } else { VisualStateManager.GoToState(this, "InvalidUnfocused", useTransitions); } } else { VisualStateManager.GoToState(this, "Valid", useTransitions); } } internal static void OnVisualStatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is Control control) { control.UpdateVisualState(); } } // // Summary: // Called to remeasure a control. // // Parameters: // constraint: // The maximum size that the method can return. // // Returns: // The size of the control, up to the maximum specified by constraint. protected override Size MeasureOverride(Size constraint) { int visualChildrenCount = VisualChildrenCount; if (visualChildrenCount > 0) { UIElement uIElement = (UIElement)GetVisualChild(0); if (uIElement != null) { uIElement.Measure(constraint); return uIElement.DesiredSize; } } return new Size(0.0, 0.0); } // // Summary: // Called to arrange and size the content of a System.Windows.Controls.Control object. // // // Parameters: // arrangeBounds: // The computed size that is used to arrange the content. // // Returns: // The size of the control. protected override Size ArrangeOverride(Size arrangeBounds) { int visualChildrenCount = VisualChildrenCount; if (visualChildrenCount > 0) { ((UIElement)GetVisualChild(0))?.Arrange(new Rect(arrangeBounds)); } return arrangeBounds; } internal bool ReadControlFlag(ControlBoolFlags reqFlag) { return (_controlBoolField & reqFlag) != 0; } internal void WriteControlFlag(ControlBoolFlags reqFlag, bool set) { if (set) { _controlBoolField |= reqFlag; } else { _controlBoolField &= (ControlBoolFlags)(ushort)(~(int)reqFlag); } } } #if false // Decompilation log '15' items in cache ------------------ Resolve: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\mscorlib.dll' ------------------ Resolve: 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xaml.dll' ------------------ Resolve: 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Found single assembly: 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\WindowsBase.dll' ------------------ Resolve: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll' ------------------ Resolve: 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Found single assembly: 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\PresentationCore.dll' ------------------ Resolve: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ------------------ Resolve: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Xml.dll' ------------------ Resolve: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Found single assembly: 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Load from: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.Core.dll' ------------------ Resolve: 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'UIAutomationProvider, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'ReachFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Could not find by name: 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ------------------ Resolve: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ------------------ Resolve: 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Could not find by name: 'System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' #endif