原文:WPF中的可视化对象(Visual)

这是MSDN对Visual的解释:
Visual class:
Provides rendering support in WPF, which includes hit testing, coordinate transformation, and bounding box calculations.

下面是关于Visual类的继承关系图,它清楚地表明了相关的层次关系:
System.Object
        System.Windows.Threading.DispatcherObject
                System.Windows.DependencyObject
                        System.Windows.Media.Visual
                                System.Windows.Media.ContainerVisual (支持包含其他Visual对象)
                                        System.Windows.Media.DrawingVisual
                                        System.Windows.Media.HostVisual
                                System.Windows.UIElement
                                        System.Windows.FrameworkElement
                                                System.Windows.Documents.Adorner
                                                System.Windows.Documents.AdornerLayer
                                                System.Windows.Documents.DocumentReference
                                                System.Windows.Documents.FixedPage
                                                System.Windows.Documents.Glyphs
                                                System.Windows.Documents.PageContent
                                                System.Windows.Interop.HwndHost
                                                Microsoft.Windows.Themes.ScrollChrome
                                                Microsoft.Windows.Themes.BulletChrome
                                                Microsoft.Windows.Themes.ScrollChrome
                                                System.Windows.Controls.Panel
                                                System.Windows.Controls.Control
                                                System.Windows.Controls.AccessText
                                                System.Windows.Controls.AdornedElementPlaceholder
                                                System.Windows.Controls.Decorator
                                                System.Windows.Controls.ContentPresenter
                                                System.Windows.Controls.Image
                                                System.Windows.Controls.InkCanvas
                                                System.Windows.Controls.ItemsPresenter
                                                System.Windows.Controls.MediaElement
                                                System.Windows.Controls.Page
                                                System.Windows.Controls.TextBlock
                                                System.Windows.Controls.ToolBarTray
                                                System.Windows.Controls.Viewport3D
                                                System.Windows.Shapes.Shape
                                                System.Windows.Controls.Primitives.GridViewRowPresenterBase
                                                System.Windows.Controls.Primitives.DocumentPageView
                                                System.Windows.Controls.Primitives.Popup
                                                System.Windows.Controls.Primitives.TickBar
                                                System.Windows.Controls.Primitives.Track
                                System.Windows.Media.Media3D.Viewport3DVisual 

再简洁点:
System.Object
        System.Windows.Threading.DispatcherObject
                System.Windows.DependencyObject
                        System.Windows.Media.Visual
                                System.Windows.Media.ContainerVisual
                                System.Windows.UIElement
                                        System.Windows.FrameworkElement
                                System.Windows.Media.Media3D.Viewport3DVisual

Visual:是WPF中用以呈现点击测试(与一个点、矩形、区域或其它对象之间执行像素级的点击检测,比如判断鼠标是否在一个对象内等),坐标转换和计算可视化对象尺寸范围的类。

以下是Visual,UIElement,FrameworkElement的构造示意:
public abstract class Visual : DependencyObject
public class UIElement : Visual, IAnimatable, IInputElement
public class FrameworkElement : UIElement, IFrameworkInputElement, IInputElement, ISupportInitialize

从Visual的构造看,它是继承于DependencyObject的抽像类。
而UIElement继承自Visual,FrameworkElement又继承自UIElement。

Visual是所有FrameworkElement的抽象基类。它为在WPF中写新的控件提供了入口点,在许多方面,你可以把它想像成为相当于Win32应用程序模式下的window句柄(HWND)。
Visual对象是WPF的核心对象,其主要角色是提供呈现支持。用户控件,如按钮Button和文本框TextBox,都从Visual类继承,并使用Visual定义的属性来维持它们的呈现数据。

Visual对象支持:
输入显示: 显示可视化的内容。
变换: 对可视化对象进行变换(比如尺寸变换、坐标转换等)。
裁切: 对可视化对象在裁切区域进行裁切之后显示。
点击测试(Hit testing):  检测一个指定的坐标(点)或几何对象是否在指定的可视化对象之范围内。
矩形范围计算:  确定Visual对象所涵盖的矩形区域。

架构上,Visual对象不支持包括其他应用程序开发需要的其他WPF特性:如:事件处理、版面布局、样式、数据绑定、全球化。

WPF中的可视化对象(Visual)的更多相关文章

  1. WPF中Logical Tree和Visual Tree的区别

    The Logical TreeThe logical tree describes the relations between elements of the user interface. The ...

  2. 【WPF学习】第四十五章 可视化对象

    前面几章介绍了处理适量适中的图形内容的最佳方法.通过使用几何图形.图画和路径,可以降低2D图形的开销.即使正在使用复杂的具有分层效果的组合形状和渐变画刷,这种方法也仍然能够正常得很好. 然而,这样设计 ...

  3. WPF中的依赖项属性

    Form cnblogs 桂素伟 随着WPF的推广,不得不重新拾起WPF来,因为这块的产品越来越多. 只能跟着MSDN来学了,所以想是在这里记录下学习的过程和对知识的理解. 先从最基本的吧,依赖项属性 ...

  4. WPF中的三维空间(1)

    原文:WPF中的三维空间(1) WPF中可以创建三维几何图形,支持3D对象的应用,支持从3D Max等软件将3D文件obj导入设计中,但是目前还不支持将材质同时导入,这样需要在WPF中对3D对象重新设 ...

  5. WPF中的依赖项属性(转)

    出处:https://www.cnblogs.com/axzxs2001/archive/2010/04/25/1719857.html 随着WPF的推广,不得不重新拾起WPF来,因为这块的产品越来越 ...

  6. 在 WPF 中使用 MahApps.Metro.IconPacks 提供的大量图标

    MahApps.Metro.IconPacks https://github.com/MahApps/MahApps.Metro.IconPacks 提供了大量的高质量的图标供WPF使用,极其方便. ...

  7. WPF中实现图片文件转换成Visual对象,Viewport3D对象转换成图片

    原文:WPF中实现图片文件转换成Visual对象,Viewport3D对象转换成图片 1.图片文件转换成Visual对象 private Visual CreateVisual(string imag ...

  8. WPF中的逻辑树和可视化树

    WPF中的逻辑树是指XAML元素级别的嵌套关系,逻辑树中的节点对应着XAML中的元素. 为了方便地自定义控件模板,WPF在逻辑树的基础上进一步细化,形成了一个“可视化树(Visual Tree)”,树 ...

  9. WPF中的Visual Tree和Logical Tree与路由事件

    1.Visual Tree和Logical TreeLogical Tree:逻辑树,WPF中用户界面有一个对象树构建而成,这棵树叫做逻辑树,元素的声明分层结构形成了所谓的逻辑树!!Visual Tr ...

随机推荐

  1. 可直接复制粘贴的boostrap图标库网址

    1:http://fontawesome.dashgame.com/ 2:http://www.kuiyu.net/art-34.html 3:http://www.bootcss.com/p/fon ...

  2. 【t099】最接近神的人

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 破解了符文之语,小FF开启了通往地下的道路.当他走到最底层时,发现正前方有一扇巨石门,门上雕刻着一幅古 ...

  3. [React] Setup 'beforeunload' listener

    In this lesson we'll show how to take a beforeUnload call and convert it to a declarative React Comp ...

  4. java开发中序列化与反序列化起到的作用

    基本概念: 序列化是将对象状态转换为可保持或传输的格式的过程.与序列化相对的是反序列化,它将流转换为对象. 这两个过程结合起来,能够轻松地存储和数据传输. 特别在网络传输中,它的作用显得尤为重要.我们 ...

  5. yield return

    一次被yield return坑的历程.   事情的经过是这样的: 我用C#写了一个很简单的一个通过迭代生成序列的函数. public static IEnumerable<T> Iter ...

  6. 学习Numpy

    1.什么是numpy NumPy系统是Python的一种开源的数值计算扩展.这种工具可用来存储和处理大型矩阵,比Python自身的嵌套列表(nested list structure)结构要高效的多( ...

  7. [Docker] Create a Volume

    We can create volumn to keep the data, even we stop the container and restart again, the data won't ...

  8. Android中动态设置GridView的列数、列宽和行高

    在使用GridView时我们知道,列数是可以通过设计时的属性来设置的,列的宽度则是根据列数和GridView的宽度计算出来的.但是有些时候我们想实现列数是动态改变的效果,即列的宽度保持某个值,列的数量 ...

  9. pycharm Zooming in the Editor

    https://www.jetbrains.com/help/pycharm/zooming-in-the-editor.html To enable changing font size in th ...

  10. HDU 5072 Coprime 同色三角形问题

    好吧,我承认就算当时再给我五个小时我也做不出来. 首先解释同色三角形问题: 给出n(n >= 3)个点,这些点中的一些被涂上了红色,剩下的被涂上了黑色.然后将这些点两两相连.于是每三个点都会组成 ...