WPF core object model-class diagram and parsing, wpf Object Model
DispatcherObject is a base class. by inheriting this class, you can obtain the Dispatcher object that accesses the UI thread that creates the object. Through the Dispatcher object, you can merge the code segment into the UI thread for execution.
DependencyObject is the core base class used to implement the dependency attribute mechanism. Dependency Property is a more powerful property model than CLR properties. This model supports changing notifications, default value inheritance, and other features, and can reduce the attribute storage space. DependencyObject supports dependency attribute mechanisms through methods such as GetValue and SetValue. Each of the following basic classes that inherit the class: Visual, Visual3D, TriggerBase, Freezable, and Their Derived classes are supported by the dependency attribute mechanism.
The DependencyProperty class represents the dependency attribute, which includes attributes such as name, type, and attribute type. You can use the Register static method to Register the dependency attribute and RegisterAttached static method to Register the additional attribute.
Directly inherit the base class DispatcherObject, including FrameworkTemplate and Style. FrameworkTemplate is used to support the template mechanism and Style is used to support the Style mechanism.
The inherited FrameworkTemplate includes the data template DataTemplate, the control template ControlTemplate, And the ItemsPanelTemplate. DataTemplate is used to customize the data presentation mode. You can specify DataType to uniformly customize the presentation mode of a data type. HierarchicalDataTemplate inherits DataTemplate, which indicates a data template with a hierarchical structure. ItemsSource can be used to indicate the data source bound to the child level, and ItemTemplate can be used to represent the data presentation mode of the Child level. You can use ControlTemplate to customize the display mode of controls and set triggers. Use ItemsPanelTemplate to customize the entry layout of Multiple content controls.
The Style Class is used for Style extraction. styles and other resources are placed in the resource dictionary ResourceDictionary. Style uses the TargetType attribute to specify the type to be applied, the BasedOn attribute to specify the base Style, the Setter value to set the attribute in Setters, and the trigger can be added to Triggers.
ResourceDictionary can merge resource dictionaries through MergedDictionaries, specify the referenced resource dictionary address through Source, and search for resources through the indexer.
The RoutedEvent class is used to support another important mechanism for routing events. RoutedEvent attributes include name, type, routing policy, and processor type. Use the static method of RegisterRoutedEvent of EventManager to register a route event.
DispatcherTimer is the UI thread timer. You can set the Interval, whether to enable IsEnabled, specify the processing logic through the Tick event, and Start and Stop the timer through the Start and Stop methods.
Application indicates the Application. The Current instance is obtained through Current. MainWindow gets the main window. You can add Application-level Resources in Resources and set the startup page through StartupUri.
The direct Derived classes of the core base class DependencyObject are Visual, Visual3D, TriggerBase, and Freezable.
Visual represents 2D Visual elements, Visual 3D represents 3D Visual elements, and UIElement3D inherits Visual3D represents 3D UI elements. It also has two Derived classes: ModelUIElement3D and ContainerUIElement3D.
TriggerBase is used to support the Trigger mechanism. Its Derived classes include Trigger, MultiTrigger, DataTrigger, MultiDataTrigger, and EventTrigger.
Animatable is a derived class of Freezable. It has two Derived classes: Brush and ImageSource, which respectively represent the image source and image source. Paint Brush includes solid Color paint brush SolidColorBrush, you can set the Color, gradient Paint Brush GradientBrush, you can set the gradient endpoint GradientStop, and tile paint brush TileBrush, you can set the stretch mode. GradientBrush is classified into Linear and Radial. Image painter ImageBrush is a TileBrush that allows you to set the image source ImageSource.
The derived classes of ImageSource include BitmapSource, DrawingImage, and D3DImage. BitmapSource has two Derived classes: BitmapImage and WriteableBitmap.
Directly inheriting UIElement is FrameworkElement. UIElement is located in the WPF core layer PresentationCore, and FrameworkElement and Its Derived classes are located in the WPF framework layer PresentationFramework. UIElement provides Clip cropping, command binding CommandBindings, input binding InputBindings, whether IsEnabled, transparency Opacity, rendering transform RenderTransform, Visibility, and other attributes, and uses the RaiseEvent method to trigger routing events. FrameworkElement provides the Cursor, data context DataContext, width and height, horizontal vertical alignment, Margin, resource set Resources, Style, Tag, ToolTip, triggers and other attributes of the trigger set. You can use the SetBinding method to set binding.
VisualStateManager, VisualStateGroup, and VisualState are used to implement the visual state management mechanism.
Controls Control, text block TextBlock, Image, Page, decoration Decorator, Panel, pop-up layer Popup, Shape and Shape directly inherit FrameworkElement, which are all framework elements.
TextBlock can be used to set the TextAlignment of Text and Text. You can set Source and Stretch mode for Image. You can set Content and Title on Page. Popup can be used to set the Child element, whether to enable attributes such as IsOpen and position Placement.
The Decorator is the base class of the decoration element. You can set the Child element. There are two Derived classes, Border and view box Viewbox. Border can be used to set Background, Border brush BorderBrush, Border Width BorderThickness, Corner radius CornerRadius and Padding. The Viewbox can be configured with the Stretch mode Stretch and Stretch direction StretchDirection.
Panel is the base class of the layout container. You can set the background and add sub-elements. Its derived class has a Grid layout. You can set row and column definitions, STACK layout StackPanel, set direction, Canvas layout, dock layout DockPanel, and stream layout WrapPanel, you can set the direction of arrangement and the width and height of items, uniform grid layout UniformGrid, and virtual base class VirtualizingPanel. VirtualizingStackPanel is an implementation of VirtualizingPanel.
Shape is the basis class of Shape, including Fill painting brush Fill, wire box painting brush Stroke, wire box width StrokeThickness, Stretch mode Stretch and other attributes. The derived class is a Rectangle, an elliptical Ellipse, a Line, and a Path.
Finally, let's talk about the system of the Control extremely derived class. Control includes Background, border paint brush BorderBrush, Border Width BorderThickness, FontFamily, FontSize, FontWeight, Foreground color Foreground, and horizontal and vertical content, padding and Template of the control. Its Derived classes include ContentControl and ItemsControl, which represent controls with single content and controls with multiple content, as well as TextBoxBase and RangeBase.
The derived classes of RangeBase are ProgressBar and Slider. TextBoxBase's derived classes are TextBox and RichTextBox.
ContentControl has a single item. You can set Content, Content template ContentTemplate, or Content template selector ContentTemplateSelector. There are two important Derived classes: Window, user control, ToolTip, ScrollViewer, Frame, and other derived classes, as well as HeaderedContentControl and ButtonBase.
HeaderedContentControl allows you to set headers, HeaderTemplate, Header template selector HeaderTemplateSelector, derived class: Expander, group container GroupBox, Tab item TabItem, etc.
ButtonBase allows you to set the click mode, Command, Command parameter CommandParameter, and derived class to Button and ToggleButton. ToggleButton can be used to set whether to select IsChecked and IsThreeState in three states, as well as two Derived classes, single-member RadioButton and check box CheckBox. RadioButton can be used to set group name GroupName.
ItemsControl has multiple items. You can set attributes such as ItemsSource, ItemTemplate, itemtemtemplate selector, ItemTemplateSelector, ItemsPanel, ItemContainerStyle, and ItemContainerStyleSelector. There are two Derived classes: HeaderedItemsControl and Selector.
HeaderedItemsControl allows you to set headers, headertemplates, headertemplates, HeaderTemplateSelector, and derived classes to be Tree View items such as TreeViewItem.
Selector can be set to select an index SelectedIndex or select an item SelectedItem. The derived class is multi-Selector. The drop-down box ComboBox, ListBox, and Tab control TabControl. DataGrid is a derived class of MultiSelector.