WPF中的可视化对象(Visual)

123 篇文章 2 订阅
116 篇文章 9 订阅

这是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特性:如:事件处理、版面布局、样式、数据绑定、全球化。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值