Before the beginning of the article, we should introduce a person: Sean Sexton. Software Engineer from Minnesota dual city, who has a deep passion for C # And WPF. He maintains two blogs: 2,000 Things You shoshould Know About C # And 2,000 Things You shoshould Know About WPF. He updates an important and easy-to-Forget knowledge of WPF and C # Every day in a 150-word short language similar to Weibo. Follow's blog has been around for a while and I hope to share it with you.
In this series, I will not only translate each of his tips, but also add my own ideas and opinions in development. I hope that I can show my masters in a closer language. In this series, I hope that I can stick to it as well, and every day's progress can make great achievements.
If you want to know more about this great programmer, this is an interview link. In this interview, he talked about his life and his views on programming-related learning. I think it will be of great help to everyone, there will be a translation of this interview article for you to read later. I hope you will pay attention to it.
Here, we solemnly note that this series is based on Mr Sean Sexton's english blog, where I have taken on translation and remarks.
Previous Article: <1-7> WPF, rendering, vector, layout, style, template, command
Previous Article: <8-14> xaml, page, 3d, version, wpf, silverlight, asp.net
[Xiao JIU's school is dedicated to describing extraordinary technologies in ordinary languages. If you want to reprint it, please indicate the source: xiaojiu's school. Cnblogs.com/xfuture]
#15 system. windows namespace
The namespace of most of the classes related to the wpf user interface is system. windows or its sub-namespaces.
The following lists some classes in the system. window namespace:
1 Application – Encapsulated a WPF application 2 Clipboard – Transfer data to/from clipboard 3 ContentElement – Base class for contents elements, for flow-style presentation 4 DataObject – Transfering data 5 DataTemplate – Visual structure of a data object 6 DependencyObject – Object that participates in dependency property system 7 DependencyProperty – Properties that support data binding, inheritance, etc. 8 EventManager – Event-related utility methods 9 FrameworkElement – Extends UIElement & provides support for logical tree, et al10 MessageBox - Displays a message box11 ResourceDictionary – Dictionary that contains WPF resources12 RoutedEvent – Routed event13 Style – Sharing of properties/resources between instances14 UIElement – Base class for graphical elements15 UIElement3D – Base class for 3D elements16 Window – Window in user interface
#16 independent and browser-hosted applications
Wpf can create an independent windows application to run in a windows environment or create an application hosted by a browser to run in a browser. Applications hosted by browsers are also called xbaps (xaml browser applications ).
The published XBAP is hosted on a web server. The visitor machine first downloads and installs the silverlight plug-in required by the application. When the user browses the xbap page for the first time, the user interface is displayed in the browser window.
XBAPS can run perfectly in ie and firefox.
#17 WPF units
In windows forms development, the control size is generated based on pixels. The wpf unit is used in wpf.
1 wpf unit = 1/96 inch. This indicates that in 96 DPI, a wpf unit is a pixel (pixel ). This means that at 120dpi, a wpf unit is 1.25 pixel.
Since all the elements of WPF are drawn in wpf units, all controls are based on the DPI of the device system. This ensures the same physical size on different devices. In other words, the elements in a 96WPF unit are 1 inch (96 pixel = 1 inch) in both 96 DPI and 120dpi ).
In Windows Form, if you want to achieve device independence, you need to set AutoScaleMode, but it is automatic in WPF.
Calculation formula: # pixels = (# WPF Units) * (DPI/96)
#18 WPF Structure
The following structure diagram shows the dependency between some of WPF's main dll files:
The dll in is listed below:
System. Windows. Presentation. dll-Contains some types related to add-ins
PresentationFramework. Aero. dll-Implements Aero theme for WPF controls
- PresentationFramework. Classic. dll-Implements Classic theme for WPF controls
- PresentationFramework. dll-Contains most of the main WPF controls, as well as support for data binding
- PresentationUI. dll-Contains some resources related to themes & some support classes for System. Windows. Documents
- ReachFramework. dll-Contains types related to printing and XPS documents
- System. Printing. dll-Contains main types related to printing
- PresentationCore. dll-Lower level types for visual rendering like UIElement. Also DragDrop support.
- System. Windows. Input. Manipulations. dll-Implementation of input manipulators
- UIAutomationProvider. dll-Support for UI Automation (for accessibility)
- WindowsBase. dll-Lower-level types likeDependencyObjectAndDependencyProperty
- UIAutomationTypes. dll-Basic types related to UI Automation
#19 WPF visualization object (Visual Class)
The Visual class is the base class for rendering WPF windows and page objects. Hittest is provided to perform pixel-level click detection between a vertex, rectangle, area, or other objects, such as determining whether the mouse is in an object ), cut, coordinate transformation, and rendering itself. It provides a wpf visual tree model.
The following is the construction of Visual, UIElement, and FrameworkElement: publicAbstractClassVisual:DependencyObjectPublic classUIElement:Visual, IAnimatable, IInputElement public classFrameworkElement:UIElement, IFrameworkInputElement, IInputElement, ISupportInitialize
From the perspective of Visual construction, it is the image class inherited from DependencyObject. While UIElement inherits from Visual, FrameworkElement inherits from UIElement. Visual is the abstract base class of all frameworkelements. It provides an entry point for writing new controls in WPF. In many ways, you can think of it as a Windows handle (HWND) in Win32 application mode ). A Visual object is the core object of WPF. Its main role is to provide rendering support. User controls, such as Button and TextBox, are inherited from the Visual class and use the properties defined by Visual to maintain their rendering data.
#20 WPF UIElement Class
UIElement inherits Visual and supports basic user interaction.
Including layout behavior, parent-child relationship, drawing and arrangement, responding to user input, inputting events from keyboard and mouse, binding commands, managing Focus, and sending and receiving route events, bubble/tunnel tree.
#21 FrameworkElement
FrameworkElement inherits from UIElement and is the parent class of all controls.
FrameworkElement is added based on UIElement:
1. layout. Implemented some layout attributes: HorizontalAlignment, MinWidth and Margin
2. Use the BeginStoryboard method to generate an animation
3. Data Binding
4. template binding
5. Style
The FrameworkElement class is the most important element in the logic tree (including the layers of visual objects on the user interface.
Note: The difference between the logical tree and the visual tree. In fact, the logical tree is the smallest element of the control, while the visual view is the deepest analysis. The logic tree is the same as the XAML layout. You can determine through:
The left is the logical tree, and the right is the visual tree.
Coming soon, basic articles 22-28