WPF control self-painting--the definition of the base, control class

Source: Internet
Author: User
Tags border color

Used to record your own learning WPF controls, the great god please drift over ...

WPF Control class inheritance diagram

All controls that can customize the template are inherited from control, so let's look at what's in the Contorl class. Prepare for customizing the template for future controls. Let's just take a look at the definition of the control class in WPF

1 namespaceSystem.Windows.Controls2 {3    Public classcontrol:frameworkelement4   {5      Public Static ReadOnlyDependencyProperty Borderbrushproperty; 6      Public Static ReadOnlyDependencyProperty Borderthicknessproperty;7      Public Static ReadOnlyDependencyProperty Backgroundproperty; 8      Public Static ReadOnlyDependencyProperty Foregroundproperty; 9      Public Static ReadOnlyDependencyProperty Fontfamilyproperty; Ten      Public Static ReadOnlyDependencyProperty Fontsizeproperty;  One      Public Static ReadOnlyDependencyProperty Fontstretchproperty;  A      Public Static ReadOnlyDependencyProperty Fontstyleproperty;  -      Public Static ReadOnlyDependencyProperty Fontweightproperty; -      Public Static ReadOnlyDependencyProperty Horizontalcontentalignmentproperty; the      Public Static ReadOnlyDependencyProperty Verticalcontentalignmentproperty; -      Public Static ReadOnlyDependencyProperty Tabindexproperty; -      Public Static ReadOnlyDependencyProperty Istabstopproperty; -      Public Static ReadOnlyDependencyProperty Paddingproperty; +      Public Static ReadOnlyDependencyProperty Templateproperty;
The above is the definition of dependency property, mainly see the following properties and methods - Public Static ReadOnlyRoutedEvent previewmousedoubleclickevent; + Public Static ReadOnlyRoutedEvent mousedoubleclickevent;
Two of the above are routed events A PublicControl ();
Call this event when the template has changed at protected Virtual voidontemplatechanged (ControlTemplate oldtemplate, ControlTemplate newtemplate); - Public Override stringToString (); - protected Virtual voidOnpreviewmousedoubleclick (MouseButtonEventArgs e); - protected Virtual voidOnmousedoubleclick (MouseButtonEventArgs e); - protected Overridesize measureoverride (size constraint); - protected Overridesize arrangeoverride (size arrangebounds); in[Bindable (true)] -[Category ("appearance")] to PublicBrush BorderBrush {Get;Set; } Border Color Paint Brush +[Bindable (true)] -[Category ("appearance")] the PublicThickness BorderThickness {Get;Set; } Border size *[Bindable (true)] $[Category ("appearance")]Panax Notoginseng PublicBrush Background {Get;Set; } Background color -[Category ("appearance")] the[Bindable (true)] + PublicBrush Foreground {Get;Set; } Foreground color A[Bindable (true)] the[Category ("appearance")] + [Localizability (Localizationcategory.font)] - PublicFontFamily FontFamily {Get;Set; } Font $[Category ("appearance")] $ [Localizability (Localizationcategory.none)] -[TypeConverter (typeof(Fontsizeconverter))] -[Bindable (true)] the Public DoubleFontSize {Get;Set; } Font size -[Bindable (true)]Wuyi[Category ("appearance")] the PublicFontStretch FontStretch {Get;Set; } Font stretch describes the degree to which a font shape is stretched from its normal aspect ratio, which is the original scale of the width and height specified for the glyphs in the font. -[Bindable (true)] Wu[Category ("appearance")] - PublicFontStyle FontStyle {Get;Set; } Font style, setting the Tilt property of the font About[Category ("appearance")] $[Bindable (true)] - PublicFontWeight FontWeight {Get;Set; } Font Bold effect -[Category ("Layout")] -[Bindable (true)] A PublicHorizontalAlignment Horizontalcontentalignment {Get;Set; } This property is used to set the horizontal position of the control relative to the parent control, rather than the placement of the contents within the control +[Bindable (true)] the[Category ("Layout")] - PublicVerticalAlignment Verticalcontentalignment {Get;Set; } $[Category ("Behavior")] the[Bindable (true)] the Public intTabIndex {Get;Set; } Supports tab toggle focus to set the order of tab Toggle the[Category ("Behavior")] the[Bindable (true)] - Public BOOLIstabstop {Get;Set; } Used to control whether the TAB key is accepted for focus switching in[Category ("Layout")] the[Bindable (true)] the PublicThickness Padding {Get;Set; } The spacing between the content within the control and the bounds of the control
Template properties, which are described in detail later in the self-painting control. About PublicControlTemplate Template {[Targetedpatchingoptout ("performance critical to-inline this type of method across NGen image boundaries")]Get;Set; } the protected Internal Virtual BOOLhandlesscrolling {Get; } Gets a value that indicates whether the combo box supports scrolling. the Public EventMousebuttoneventhandler Previewmousedoubleclick; the Public EventMousebuttoneventhandler MouseDoubleClick; + } -}

The above properties are relatively simple, just a simple introduction, when we self-draw the control to know that these properties are good.

WPF control self-painting-the definition of the base, control class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.