WPF基础四:UI的相关类 (8)FrameworkElement的其他派生类

目录

2.8 其他FrameworkElement的派生

2.8.1 AccessText 

2.8.2 AdornedElementPlaceholder

2.8.3 ColumnDefinition

2.8.4 ContentPresenter

2.8.5 ControlTemplate

2.8.6 Image

2.8.7 InkCanvas

2.8.8 ItemsPanelTemplate

2.8.9 ItemsPresenter

2.8.10 MediaElement

2.8.11 Page

2.8.12 RowDefinition

2.8.13 ScrollContentPresenter

2.8.14 TextBlock

2.8.15 Viewport3D

2.8.16 WebBrowser


2.8 其他FrameworkElement的派生


2.8.1 AccessText 

用下划线来指定用作访问键的字符。

如果内容包含多个下划线字符,则只会将第一个下划线字符转换为, AccessKey 其他下划线将显示为普通文本。 如果要转换为访问键的下划线不是第一个下划线,请在要转换的下划线前面使用两个连续的下划线。 例如,以下代码包含一个访问键,并显示为 _Hello W orld:

<AccessText>__Hello_World</AccessText>   

由于 H 前面的下划线为 double,因此 W key 注册为访问键。

若要 AccessText 在控件样式中用作内容宿主,请 RecognizesAccessKey 在中设置 ContentPresenter ,如以下示例所示:

<ContentPresenter RecognizesAccessKey="True"/>   
    public class AccessText : FrameworkElement, IAddChild
    {
        public static readonly System.Windows.DependencyProperty BackgroundProperty;
        public static readonly System.Windows.DependencyProperty BaselineOffsetProperty;
        public static readonly System.Windows.DependencyProperty FontFamilyProperty;
        public static readonly System.Windows.DependencyProperty FontSizeProperty;
        public static readonly System.Windows.DependencyProperty FontStretchProperty;
        public static readonly System.Windows.DependencyProperty FontStyleProperty;
        public static readonly System.Windows.DependencyProperty FontWeightProperty;
        public static readonly System.Windows.DependencyProperty ForegroundProperty;
        public static readonly System.Windows.DependencyProperty LineHeightProperty;
        public static readonly System.Windows.DependencyProperty LineStackingStrategyProperty;
        public static readonly System.Windows.DependencyProperty TextAlignmentProperty;
        public static readonly System.Windows.DependencyProperty TextDecorationsProperty;
        public static readonly System.Windows.DependencyProperty TextEffectsProperty;
        public static readonly System.Windows.DependencyProperty TextProperty;
        public static readonly System.Windows.DependencyProperty TextTrimmingProperty;
        public static readonly System.Windows.DependencyProperty TextWrappingProperty;

        //用于以只读方式访问第一个下划线字符后面的字符。
        public char AccessKey { get; }

        //获取或设置填充内容区域的 Brush。
        public System.Windows.Media.Brush Background { get; set; }

        //获取或设置一个值,该值调整文本在 AccessText 元素中的基线偏移位置。
        public double BaselineOffset { get; set; }

        //获取或设置要用于 AccessText 元素的字体系列。
        public System.Windows.Media.FontFamily FontFamily { get; set; }

        //获取或设置要用于 AccessText 元素的字体大小。
        public double FontSize { get; set; }

        //获取或设置一个 FontStretch 属性,该属性从 FontFamily 中选择一个正常、压缩或扩展的字体。
        public System.Windows.FontStretch FontStretch { get; set; }

        //获取或设置要用于 AccessText 元素的字体样式。
        public System.Windows.FontStyle FontStyle { get; set; }

        //获取或设置要用于 AccessText 元素的字体粗细。
        public System.Windows.FontWeight FontWeight { get; set; }

        //获取或设置用于绘制元素的文本内容的 Brush。
        public System.Windows.Media.Brush Foreground { get; set; }

        //获取或设置每个行框的高度。
        public double LineHeight { get; set; }

        //获取或设置如何强制应用 LineHeight 属性。
        public System.Windows.LineStackingStrategy LineStackingStrategy { get; set; }

        //获取一个循环访问该 AccessText 元素的逻辑子元素的枚举数。
        protected internal override System.Collections.IEnumerator LogicalChildren { get; }

        //获取或设置 AccessText 元素所显示的文本。
        public string Text { get; set; }

        //获取或设置内容的水平对齐方式。
        public System.Windows.TextAlignment TextAlignment { get; set; }

        //获取或设置添加到 AccessText 元素的文本的修饰。
        public System.Windows.TextDecorationCollection TextDecorations { get; set; }

        //获取或设置添加到 AccessText 元素的文本的效果。
        public System.Windows.Media.TextEffectCollection TextEffects { get; set; }

        //获取或设置在 AccessText 元素的文本内容溢出行框时应如何裁剪这些内容。
        public System.Windows.TextTrimming TextTrimming { get; set; }

        //获取或设置当 AccessText 元素的文本内容溢出行框时是否换行。
        public System.Windows.TextWrapping TextWrapping { get; set; }

        //获取可见子元素的数量。
        protected override int VisualChildrenCount { get; }

        //排列 AccessText 对象的内容并调整其大小。
        protected override sealed System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize);

        //获取可见子元素的索引。
        protected override System.Windows.Media.Visual GetVisualChild(int index);

        //重新测量控件。
        protected override sealed System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //有关此成员的说明,请参见 AddChild(Object)。
        void IAddChild.AddChild(object value);

        //有关此成员的说明,请参见 AddText(String)。
        void IAddChild.AddText(string text);
    }

2.8.2 AdornedElementPlaceholder

表示 ControlTemplate 中使用的元素,该元素用于指定修饰控件相对于 ControlTemplate 中的其他元素所放置的位置。

仅当你要创建一个用作 ControlTemplate 自定义验证的, ErrorTemplate 以便在用户输入无效时提供可视反馈时,才使用此类。

数据绑定验证错误

例如,当输入无效时,您可能希望在文本框旁显示一个红色感叹号,如下图所示。数据绑定验证错误

 

XAML 对象元素用法

<AdornedElementPlaceholder/>  
    public class AdornedElementPlaceholder : FrameworkElement, IAddChild
    {
        //获取此 UIElement 对象为其保留空间的 AdornedElementPlaceholder。
        public System.Windows.UIElement AdornedElement { get; }

        //获取或设置此 AdornedElementPlaceholder 对象的单一子对象。
        public virtual System.Windows.UIElement Child { get; set; }

        //获取 AdornedElementPlaceholder 对象的逻辑子元素的枚举器。
        protected internal override System.Collections.IEnumerator LogicalChildren { get; }

        //获取可见子对象的数目。
        protected override int VisualChildrenCount { get; }

        //定位第一个可见子对象并返回此 AdornedElementPlaceholder 对象所要求的布局大小。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeBounds);

        //检索位于指定索引处的 Visual 子对象。
        protected override System.Windows.Media.Visual GetVisualChild(int index);

        //确定 AdornedElementPlaceholder 对象的大小。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //引发 IsInitialized 事件。 当在内部将 IsInitialized 设置为 true 时,将调用此方法。
        protected override void OnInitialized(EventArgs e);

        //此类型或成员支持 Windows Presentation Foundation (WPF) 基础结构,并且不应在代码中直接使用。
        void IAddChild.AddChild(object value);

        //此类型或成员支持 Windows Presentation Foundation (WPF) 基础结构,并且不应在代码中直接使用。
        void IAddChild.AddText(string text);
    }

2.8.3 ColumnDefinition

定义将应用于 Grid 元素的特定于列的属性。

ColumnDefinition 使用其自己的特殊结构 a GridLength 来描述其宽度特征。 GridLength 允许 ColumnDefinition 支持可用空间的变量分布。

    public class ColumnDefinition : DefinitionBase
    {
        public static readonly System.Windows.DependencyProperty MaxWidthProperty;
        public static readonly System.Windows.DependencyProperty MinWidthProperty;
        public static readonly System.Windows.DependencyProperty WidthProperty;

        //获取一个值,该值表示实际计算所得的 ColumnDefinition 宽度。
        public double ActualWidth { get; }

        //获取或设置一个值,该值表示 ColumnDefinition 的最大宽度。
        public double MaxWidth { get; set; }

        //获取或设置一个值,该值表示 ColumnDefinition 的最小宽度。
        public double MinWidth { get; set; }

        //获取一个值,该值表示此 ColumnDefinition 的偏移量值。
        public double Offset { get; }

        //获取 ColumnDefinition 元素的计算所得宽度,或设置由 ColumnDefinition 定义的列的 GridLength 值。
        public System.Windows.GridLength Width { get; set; }

    }


    public abstract class DefinitionBase : FrameworkContentElement
    {
        public static readonly System.Windows.DependencyProperty SharedSizeGroupProperty;

        //获取或设置一个值,该值将 ColumnDefinition 或 RowDefinition 标识为已定义的共享调整大小属性的组的成员。
        public string SharedSizeGroup { get; set; }
    }

2.8.4 ContentPresenter

显示 ContentControl 的内容。

通常使用的 ContentPresenter 中的 ControlTemplate ContentControl 来指定要添加内容的位置。 每个 ContentControl 类型的 ContentPresenter 默认值均为 ControlTemplate 。

当 ContentPresenter 对象位于的中时, ControlTemplate ContentControl Content 、 ContentTemplate 和属性将 ContentTemplateSelector 从相同名称的属性中获取其值 ContentControl 。 可以让 ContentPresenter 属性通过设置 ContentSource 属性或绑定到模板父级的其他属性来获取这些属性的值。

ContentPresenter使用以下逻辑显示 Content :

    public class ContentPresenter : FrameworkElement
    {
        public static readonly System.Windows.DependencyProperty ContentProperty;
        public static readonly System.Windows.DependencyProperty ContentSourceProperty;
        public static readonly System.Windows.DependencyProperty ContentStringFormatProperty;
        public static readonly System.Windows.DependencyProperty ContentTemplateProperty;
        public static readonly System.Windows.DependencyProperty ContentTemplateSelectorProperty;
        public static readonly System.Windows.DependencyProperty RecognizesAccessKeyProperty;

        //获取或设置用于生成 ContentPresenter 的子元素的数据。
        public object Content { get; set; }

        //获取或设置要在自动命名别名过程中使用的基名称。
        public string ContentSource { get; set; }

        //获取或设置一个撰写字符串,该字符串指定如果 Content 属性显示为字符串,应如何设置该属性的格式。
        public string ContentStringFormat { get; set; }

        //获取或设置用于显示控件内容的模板。
        public System.Windows.DataTemplate ContentTemplate { get; set; }

        //获取或设置 DataTemplateSelector,它允许应用程序编写器为选择用于显示控件内容的模板提供自定义逻辑。
        public System.Windows.Controls.DataTemplateSelector ContentTemplateSelector { get; set; }

        //获取或设置一个值,该值指示 ContentPresenter 是否应在其样式中使用 AccessText。
        public bool RecognizesAccessKey { get; set; }

        //定位单个子元素并确定 ContentPresenter 对象的内容。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize);

        //返回要使用的模板。 这可能取决于内容或其他属性。
        protected virtual System.Windows.DataTemplate ChooseTemplate();

        //根据大小属性、边距和请求的子内容大小确定 ContentPresenter 对象的大小。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //当 ContentStringFormat 属性更改时调用。
        protected virtual void OnContentStringFormatChanged(string oldContentStringFormat, string newContentStringFormat);

        //当 ContentTemplate 更改时调用。
        protected virtual void OnContentTemplateChanged(System.Windows.DataTemplate oldContentTemplate, System.Windows.DataTemplate newContentTemplate);

        //当 ContentTemplateSelector 属性更改时调用。
        protected virtual void OnContentTemplateSelectorChanged(System.Windows.Controls.DataTemplateSelector oldContentTemplateSelector, System.Windows.Controls.DataTemplateSelector newContentTemplateSelector);

        //当 ContentTemplate 更改时调用。
        protected virtual void OnTemplateChanged(System.Windows.DataTemplate oldTemplate, System.Windows.DataTemplate newTemplate);

        //返回一个值,该值指示序列化进程是否应当对此类的实例的 ContentTemplateSelector 有效属性值进行序列化。
        public bool ShouldSerializeContentTemplateSelector();
    }

2.8.5 ControlTemplate

指定 Control 的可在其多个实例之间共享的可视结构和行为方面。

ControlTemplate允许您指定控件的可视结构。 控件作者可以定义默认设置 ControlTemplate ,应用程序作者可以重写 ControlTemplate 来重新构造控件的可视结构。

控件模板化是 WPF 样式设置和模板化模型所提供的众多功能之一。 样式设置和模板化模型为你提供了如此大的灵活性,在许多情况下,你无需编写自己的控件。 如果你是想要更改控件的可视化效果或替换现有控件的的应用程序作者 ControlTemplate ,请参阅 样式设置和模板化 主题,了解示例和深入讨论。

如果你正在编写自己的控件,请参阅 控件创作概述中的 "创建自定义控件"。

ControlTemplate旨在作为实现详细信息的自包含单元,该单元对外部用户和对象(包括样式)不可见。 操作控件模板内容的唯一方法是在同一控件模板中。

XAML 属性元素用法

<ControlTemplate>  
  <VisualTreeRootNode>
    VisualTreeNodeContents  
  </VisualTreeRootNode>  
</ControlTemplate>  

XAML 值

ControlTemplate
ControlTemplate或派生类的对象元素。

VisualTreeRootNode
单个 XAML 元素作为 (的直接子级 ControlTemplate 或) 派生类。 模板必须有一个根节点。 若要生成有用的模板,则选择为 VisualTreeRootNode 的元素应支持其自己的内容模型,通常是支持多个子元素的模型。

VisualTreeNodeContents
完成预期模板的一个或多个元素。 如果选择为 VisualTreeRootNode 的元素仅支持单个子级,则只能有一个声明为 VisualTreeNodeContents 的元素。 如果所选 VisualTreeRootNode 支持 "文本内容" 属性,则也可能会 () 提供文本内容。

    public class ControlTemplate : FrameworkTemplate
    {
        //获取或设置此 ControlTemplate 所针对的类型。
        public Type TargetType { get; set; }

        //获取根据指定条件应用属性更改或执行操作的 TriggerBase 对象的集合。
        public System.Windows.TriggerCollection Triggers { get; }

        //根据一组规则检查模板化父级。
        protected override void ValidateTemplatedParent(System.Windows.FrameworkElement templatedParent);
    }

2.8.6 Image

表示用于显示图像的控件。

Image利用类,您可以加载以下图像类型: .bmp、.gif、.ico、.jpg、.png、. wdp 和 tiff。

显示多帧图像时,仅显示第一帧。 Image 控件不支持多帧图像的动画 。

在加载图像内容之前,控件的 ActualWidth 和 ActualHeight 将报告为零,因为图像内容用于确定控件的最终大小和位置。

对于固定大小的控件, 可以设置 Width 和Height属性。 但是,若要保留媒体的纵横比,请设置 Width 或 Height 属性,但不能同时设置二者。

   public class Image : FrameworkElement, IUriContext, IProvidePropertyFallback
    {
        public static readonly System.Windows.RoutedEvent DpiChangedEvent;
        public static readonly System.Windows.RoutedEvent ImageFailedEvent;
        public static readonly System.Windows.DependencyProperty SourceProperty;
        public static readonly System.Windows.DependencyProperty StretchDirectionProperty;
        public static readonly System.Windows.DependencyProperty StretchProperty;

        //获取或设置 Image 的基本统一资源标识符 (URI)。
        protected virtual Uri BaseUri { get; set; }

        //获取或设置图像的 ImageSource。
        public System.Windows.Media.ImageSource Source { get; set; }

        //获取或设置一个值,该值描述应如何拉伸 Image 以填充目标矩形。
        public System.Windows.Media.Stretch Stretch { get; set; }

        //获取或设置一个值,该值指示如何缩放图像。
        public System.Windows.Controls.StretchDirection StretchDirection { get; set; }

        //排列图像控件并调整其大小。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize);

        //更新图像的 DesiredSize。 此方法由父 UIElement 调用,并且第一个布局处理过程。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //创建并返回此 AutomationPeer 的 Image 对象。
        protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer();

        //此图像的 DPI 呈现变更时进行调用。
        protected override void OnDpiChanged(System.Windows.DpiScale oldDpi, System.Windows.DpiScale newDpi);

        //呈现 Image 的内容。
        protected override void OnRender(System.Windows.Media.DrawingContext dc);

        //显示图像的屏幕的 DPI 发生更改后出现。
        public event System.Windows.DpiChangedEventHandler DpiChanged;

        //在图像中出现故障时发生。
        public event EventHandler<System.Windows.ExceptionRoutedEventArgs> ImageFailed;

        //此类型或成员支持 Windows Presentation Foundation (WPF) 基础结构,并且不应在代码中直接使用。
        Uri System.Windows.Markup.IUriContext.BaseUri { get; set; }
    }

2.8.7 InkCanvas

定义接收和显示墨迹笔划的区域。

InkCanvas是可用于接收和显示墨迹输入的元素。 这通常是通过使用触笔来完成的,它与数字化仪交互,使用触笔或鼠标生成墨迹笔划。 创建的笔划表示为 Stroke 对象,可通过编程方式或根据用户输入进行操作。 InkCanvas允许用户修改或删除现有的 Stroke 。

InkCanvas可以绑定到数据源。 例如,可以将 Strokes 属性绑定到:以墨迹序列化格式包含墨迹数据的以64编码的编码字符串 (ISF) ,甚至是 Strokes 另一个的属性 InkCanvas 。 您还可以将属性(例如 DefaultDrawingAttributes 和 EditingMode )绑定到其他数据源。

    public class InkCanvas : FrameworkElement, IAddChild
    {
        public static readonly System.Windows.RoutedEvent ActiveEditingModeChangedEvent;
        public static readonly System.Windows.DependencyProperty ActiveEditingModeProperty;
        public static readonly System.Windows.DependencyProperty BackgroundProperty;
        public static readonly System.Windows.DependencyProperty BottomProperty;
        public static readonly System.Windows.DependencyProperty DefaultDrawingAttributesProperty;
        public static readonly System.Windows.RoutedEvent EditingModeChangedEvent;
        public static readonly System.Windows.RoutedEvent EditingModeInvertedChangedEvent;
        public static readonly System.Windows.DependencyProperty EditingModeInvertedProperty;
        public static readonly System.Windows.DependencyProperty EditingModeProperty;
        public static readonly System.Windows.RoutedEvent GestureEvent;
        public static readonly System.Windows.DependencyProperty LeftProperty;
        public static readonly System.Windows.DependencyProperty RightProperty;
        public static readonly System.Windows.RoutedEvent StrokeCollectedEvent;
        public static readonly System.Windows.RoutedEvent StrokeErasedEvent;
        public static readonly System.Windows.DependencyProperty StrokesProperty;
        public static readonly System.Windows.DependencyProperty TopProperty;

        //获取 InkCanvas 的当前编辑模式。
        public System.Windows.Controls.InkCanvasEditingMode ActiveEditingMode { get; }

        //获取或设置一个 Brush。 画笔用于填充 InkCanvas 周围的边框区域。
        public System.Windows.Media.Brush Background { get; set; }

        //检索 InkCanvas 的子元素。
        public System.Windows.Controls.UIElementCollection Children { get; }

        //获取或设置应用于在 InkCanvas 上绘制的新墨迹笔画的绘制特性。
        public System.Windows.Ink.DrawingAttributes DefaultDrawingAttributes { get; set; }

        //获取或设置 InkCanvas 的触笔点说明
        public System.Windows.Input.StylusPointDescription DefaultStylusPointDescription { get; set; }

        //获取或设置在 InkCanvas 上动态绘制墨迹的呈现器。
        protected System.Windows.Input.StylusPlugIns.DynamicRenderer DynamicRenderer { get; set; }

        //获取或设置活动指针设备使用的用户编辑模式。
        public System.Windows.Controls.InkCanvasEditingMode EditingMode { get; set; }

        //如果触笔在与 InkCanvas 交互时发生反转,则获取或设置用户编辑模式。
        public System.Windows.Controls.InkCanvasEditingMode EditingModeInverted { get; set; }

        //获取或设置用来按点擦除 StylusShape 中墨迹的 InkCanvas。
        public System.Windows.Ink.StylusShape EraserShape { get; set; }

        //获取在 InkCanvas 上显示墨迹的墨迹显示器。
        protected System.Windows.Controls.InkPresenter InkPresenter { get; }

        //获取(确定)笔势识别组件在用户系统上是否可用。
        public bool IsGestureRecognizerAvailable { get; }

        //返回用于逻辑子级的枚举器。
        protected internal override System.Collections.IEnumerator LogicalChildren { get; }

        //获取或设置一个布尔值,该值指示是否允许用户移动 InkCanvas 上选定的墨迹笔画和/或元素。
        public bool MoveEnabled { get; set; }

        //获取或设置可粘贴到 InkCanvas 中的格式。
        public System.Collections.Generic.IEnumerable<System.Windows.Controls.InkCanvasClipboardFormat> PreferredPasteFormats { get; set; }

        //获取或设置一个布尔值,该值指示用户是否可以调整 InkCanvas 上选定的墨迹笔画和/或元素的大小。
        public bool ResizeEnabled { get; set; }

        //获取或设置 Stroke 收集的墨迹 InkCanvas 对象集合。
        public System.Windows.Ink.StrokeCollection Strokes { get; set; }

        //获取或设置一个布尔值,该值指示是否重写标准的 InkCanvas 光标功能以支持自定义光标。
        public bool UseCustomCursor { get; set; }

        //获取此元素内可视子元素的数目。
        protected override int VisualChildrenCount { get; }

        //定位子元素,并确定 InkCanvas 对象的大小。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize);

        //指示剪贴板的内容是否可以粘贴到 InkCanvas。
        public bool CanPaste();

        //将选定笔画和/或元素复制到剪贴板。
        public void CopySelection();

        //删除选定笔画和元素,并将它们复制到剪贴板。
        public void CutSelection();

        //为给定的依赖对象获取 Bottom 附加属性的值。
        public static double GetBottom(System.Windows.UIElement element);

        //返回一个由 InkCanvas 识别的应用程序笔势集合。
        public System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Ink.ApplicationGesture> GetEnabledGestures();

        //为给定的依赖对象获取 Left 附加属性的值。
        public static double GetLeft(System.Windows.UIElement element);

        //为给定的依赖对象获取 Right 附加属性的值。
        public static double GetRight(System.Windows.UIElement element);

        //检索在 FrameworkElement 中选定的 InkCanvas 对象。
        public System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.UIElement> GetSelectedElements();

        //检索一个 StrokeCollection,它表示 Stroke 上选定的 InkCanvas 对象。
        public System.Windows.Ink.StrokeCollection GetSelectedStrokes();

        //获取 InkCanvas 上选定笔画和元素的边界。
        public System.Windows.Rect GetSelectionBounds();

        //为给定的依赖对象获取 Top 附加属性的值。
        public static double GetTop(System.Windows.UIElement element);

        //重写 GetVisualChild(Int32),并从子元素集合中返回指定索引处的子元素。
        protected override System.Windows.Media.Visual GetVisualChild(int index);

        //确定给定点是否落在 InkCanvas 的呈现边界之内。
        protected override System.Windows.Media.HitTestResult HitTestCore(System.Windows.Media.PointHitTestParameters hitTestParams);

        //返回一个值,该值指示选择装饰器的哪个部分与指定点相交或包围指定点。
        public System.Windows.Controls.InkCanvasSelectionHitResult HitTestSelection(System.Windows.Point point);

        //测量子元素在布局中所需的大小,并确定 InkCanvas 对象的大小。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize);

        //引发 ActiveEditingModeChanged 事件。
        protected virtual void OnActiveEditingModeChanged(System.Windows.RoutedEventArgs e);

        //提供 InkCanvasAutomationPeer 此控件的适当实现,作为 WPF 基础结构的一部分。
        protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer();

        //引发 DefaultDrawingAttributesReplaced 事件。
        protected virtual void OnDefaultDrawingAttributesReplaced(System.Windows.Ink.DrawingAttributesReplacedEventArgs e);

        //引发 EditingModeChanged 事件。
        protected virtual void OnEditingModeChanged(System.Windows.RoutedEventArgs e);

        //引发 EditingModeInvertedChanged 事件。
        protected virtual void OnEditingModeInvertedChanged(System.Windows.RoutedEventArgs e);

        //引发 Gesture 事件。
        protected virtual void OnGesture(System.Windows.Controls.InkCanvasGestureEventArgs e);

        //每当更新此 FrameworkElement 的任何依赖属性的有效值时调用。 将在自变量参数中报告已更改的特定依赖属性。 重写 OnPropertyChanged(DependencyPropertyChangedEventArgs)。
        protected override void OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e);

        //引发 SelectionChanged 事件。
        protected virtual void OnSelectionChanged(EventArgs e);

        //引发 SelectionChanging 事件。
        protected virtual void OnSelectionChanging(System.Windows.Controls.InkCanvasSelectionChangingEventArgs e);

        //一个事件,通告用户选择并移动了所选笔画和/或元素。
        protected virtual void OnSelectionMoved(EventArgs e);

        //引发 SelectionMoving 事件。
        protected virtual void OnSelectionMoving(System.Windows.Controls.InkCanvasSelectionEditingEventArgs e);

        //引发 SelectionResized 事件。
        protected virtual void OnSelectionResized(EventArgs e);

        //引发 SelectionResizing 事件。
        protected virtual void OnSelectionResizing(System.Windows.Controls.InkCanvasSelectionEditingEventArgs e);

        //引发 StrokeCollected 事件。
        protected virtual void OnStrokeCollected(System.Windows.Controls.InkCanvasStrokeCollectedEventArgs e);

        //引发 StrokeErased 事件。
        protected virtual void OnStrokeErased(System.Windows.RoutedEventArgs e);

        //引发 StrokeErasing 事件。
        protected virtual void OnStrokeErasing(System.Windows.Controls.InkCanvasStrokeErasingEventArgs e);

        //引发 StrokesReplaced 事件。
        protected virtual void OnStrokesReplaced(System.Windows.Controls.InkCanvasStrokesReplacedEventArgs e);

        //将剪贴板的内容粘贴到 InkCanvas。
        public void Paste();
        public void Paste(System.Windows.Point point);

        //选择一组墨迹 Stroke 对象和/或 FrameworkElement 对象。
        public void Select(System.Collections.Generic.IEnumerable<System.Windows.UIElement> selectedElements);
        public void Select(System.Windows.Ink.StrokeCollection selectedStrokes);
        public void Select(System.Windows.Ink.StrokeCollection selectedStrokes, System.Collections.Generic.IEnumerable<System.Windows.UIElement> selectedElements);

        //设置给定的依赖对象设置上的 Bottom 附加属性值。
        public static void SetBottom(System.Windows.UIElement element, double length);

        //设置 InkCanvas 将要识别的应用程序笔势。
        public void SetEnabledGestures(System.Collections.Generic.IEnumerable<System.Windows.Ink.ApplicationGesture> applicationGestures);

        //设置给定的依赖对象设置上的 Left 附加属性值。
        public static void SetLeft(System.Windows.UIElement element, double length);

        //设置给定的依赖对象设置上的 Right 附加属性值。
        public static void SetRight(System.Windows.UIElement element, double length);

        //设置给定的依赖对象设置上的 Top 附加属性值。
        public static void SetTop(System.Windows.UIElement element, double length);

        //在当前编辑模式改变时发生。
        public event System.Windows.RoutedEventHandler ActiveEditingModeChanged;

        //在替换 DefaultDrawingAttributes 属性时发生。
        public event System.Windows.Ink.DrawingAttributesReplacedEventHandler DefaultDrawingAttributesReplaced;

        //在 EditingMode 对象的 InkCanvas 属性更改后发生。
        public event System.Windows.RoutedEventHandler EditingModeChanged;

        //在 EditingModeInverted 对象的 InkCanvas 属性更改后发生。
        public event System.Windows.RoutedEventHandler EditingModeInvertedChanged;

        //在 InkCanvas 检测到笔势时发生。
        public event System.Windows.Controls.InkCanvasGestureEventHandler Gesture;

        //在 InkCanvas 上的选择更改时发生。
        public event EventHandler SelectionChanged;

        //在选择了一组新墨迹笔画和/或元素时发生。
        public event System.Windows.Controls.InkCanvasSelectionChangingEventHandler SelectionChanging;

        //在用户移动了所选笔画和/或元素之后发生。
        public event EventHandler SelectionMoved;

        //在移动选定笔画和元素之前发生。
        public event System.Windows.Controls.InkCanvasSelectionEditingEventHandler SelectionMoving;

        //在用户调整了所选笔画和/或元素大小时发生。
        public event EventHandler SelectionResized;

        //在调整选定笔画和元素的大小之前发生。
        public event System.Windows.Controls.InkCanvasSelectionEditingEventHandler SelectionResizing;

        //在将用户绘制的笔画添加到 Strokes 属性时发生。
        public event System.Windows.Controls.InkCanvasStrokeCollectedEventHandler StrokeCollected;

        //在用户擦除笔画时发生。
        public event System.Windows.RoutedEventHandler StrokeErased;

        //恰好在用户擦除笔画之前发生。
        public event System.Windows.Controls.InkCanvasStrokeErasingEventHandler StrokeErasing;

        //在替换 Strokes 属性时发生。
        public event System.Windows.Controls.InkCanvasStrokesReplacedEventHandler StrokesReplaced;

        //将指定的对象添加到 InkCanvas 中。
        void IAddChild.AddChild(object value);

        //添加位于标记内的文本。 始终引发一个 ArgumentException。
        void IAddChild.AddText(string textData);

        //InkCanvas.Bottom 附加属性
        //获取或设置某元素的下边缘与其父 InkCanvas 的下边缘之间的距离。
        //see GetBottom, and SetBottom

        //InkCanvas.Left 附加属性
        //获取或设置某元素的左边缘与其父 InkCanvas 的左边缘之间的距离。
        //see GetBottom, and SetBottom

        //InkCanvas.Right 附加属性
        //获取或设置某元素的右边缘与其父 InkCanvas 的右边缘之间的距离。
        //see GetRight, and SetRight

        //InkCanvas.Top 附加属性
        //获取或设置某元素的上边缘与其父 InkCanvas 的上边缘之间的距离
        //see GetTop, and SetTop
    }

2.8.8 ItemsPanelTemplate

指定 ItemsPresenter 为 ItemsControl 的项的布局创建的面板。

ItemsPanelTemplate指定用于项的布局的面板。 GroupStyle 具有 Panel 类型为的属性 ItemsPanelTemplate 。 ItemsControl 类型具有 ItemsPanel 类型为的属性 ItemsPanelTemplate 。

每个 ItemsControl 类型都有一个默认值 ItemsPanelTemplate 。 对于 ItemsControl 类,默认 ItemsPanel 值为 ItemsPanelTemplate 指定的 StackPanel 。 对于 ListBox ,默认使用 VirtualizingStackPanel 。 对于 MenuItem ,默认使用 WrapPanel 。 对于 StatusBar ,默认使用 DockPanel 。

    public class ItemsPanelTemplate : FrameworkTemplate
    {
        //检查模板化父级是否为非 null ItemsPresenter 对象。
        protected override void ValidateTemplatedParent(System.Windows.FrameworkElement templatedParent);
    }

2.8.9 ItemsPresenter

在项控件的模板中使用,用于指定要将 ItemsPanel 定义的 ItemsControl 添加到控件的可视化树中的什么位置。

    public class ItemsPresenter : FrameworkElement
    {
        //调用以排列 ItemsPresenter 对象的内容并调整其大小。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize);

        //重写 MeasureOverride(Size) 的基类实现以度量 ItemsPresenter 对象的大小并将正确的大小返回到布局引擎。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //在内部进程或应用程序调用用于构建当前模板的可视化树的 ApplyTemplate() 时调用。
        public override void OnApplyTemplate();

        //在控件模板更改时调用。
        protected virtual void OnTemplateChanged(System.Windows.Controls.ItemsPanelTemplate oldTemplate, System.Windows.Controls.ItemsPanelTemplate newTemplate);
        
    }

2.8.10 MediaElement

表示包含音频和/或视频的控件。

使用应用程序分发媒体时,不可将媒体文件用作项目资源。 在项目文件中,必须改为将媒体类型设置为 Content 并将 CopyToOutputDirectory 设置为 PreserveNewest 或 Always

MediaElement 可在两种不同的模式中使用,具体取决于驱动控件的方式:独立模式或时钟模式。 在独立模式下使用时,与 MediaElement 图像类似,并且 Source 可以直接指定 URI。 在时钟模式下, MediaElement 可以将视为动画的目标,因此它将 Timeline 在计时树中具有相应的和 Clock 条目。 有关媒体模式的详细信息,请参阅 多媒体概述

有关 MediaElement 以独立模式控制的示例,请参阅 如何:控制 MediaElement (播放、暂停、停止、音量和速度) 

在 MediaOpened 引发事件之前, ActualWidth 控件的和 ActualHeight 将报告为零,因为媒体内容用于确定控件的最终大小和位置。 对于仅限音频的内容,这些属性将始终为零。

对于固定大小的控件, Width 可以设置和/或 Height 属性。 但是,若要保留媒体的纵横比,请设置 Width 或 Height 属性,但不能同时设置二者。

    public class MediaElement : FrameworkElement, IUriContext
    {
        public static readonly System.Windows.DependencyProperty BalanceProperty;
        public static readonly System.Windows.RoutedEvent BufferingEndedEvent;
        public static readonly System.Windows.RoutedEvent BufferingStartedEvent;
        public static readonly System.Windows.DependencyProperty IsMutedProperty;
        public static readonly System.Windows.DependencyProperty LoadedBehaviorProperty;
        public static readonly System.Windows.RoutedEvent MediaEndedEvent;
        public static readonly System.Windows.RoutedEvent MediaFailedEvent;
        public static readonly System.Windows.RoutedEvent MediaOpenedEvent;
        public static readonly System.Windows.RoutedEvent ScriptCommandEvent;
        public static readonly System.Windows.DependencyProperty ScrubbingEnabledProperty;
        public static readonly System.Windows.DependencyProperty SourceProperty;
        public static readonly System.Windows.DependencyProperty StretchDirectionProperty;
        public static readonly System.Windows.DependencyProperty StretchProperty;
        public static readonly System.Windows.DependencyProperty UnloadedBehaviorProperty;
        public static readonly System.Windows.DependencyProperty VolumeProperty;

        //获取或设置扬声器的音量比。
        public double Balance { get; set; }

        //获取一个值,该值指示已完成的缓冲进度的百分比。
        public double BufferingProgress { get; }

        //获取一个值,该值指示是否可暂停媒体。
        public bool CanPause { get; }

        //获取或设置与控制媒体播放的 MediaTimeline 关联的时钟。
        public System.Windows.Media.MediaClock Clock { get; set; }

        //获取一个百分比值,该值指示为位于远程服务器上的内容完成的下载量。
        public double DownloadProgress { get; }

        //获取一个值,该值指示媒体是否具有音频。
        public bool HasAudio { get; }

        //获取一个值,该值指示媒体是否具有视频。
        public bool HasVideo { get; }

        //获取一个值,该值指示媒体是否正在缓冲。
        public bool IsBuffering { get; }

        //获取或设置一个值,该值指示是否已静音。
        public bool IsMuted { get; set; }

        //获取或设置媒体的加载行为 MediaState。
        public System.Windows.Controls.MediaState LoadedBehavior { get; set; }

        //获取媒体的自然持续时间。
        public System.Windows.Duration NaturalDuration { get; }

        //获取与媒体关联的视频的高度。
        public int NaturalVideoHeight { get; }

        //获取与媒体关联的视频的宽度。
        public int NaturalVideoWidth { get; }

        //通过媒体的播放时间获取或设置进度的当前位置。
        public TimeSpan Position { get; set; }

        //获取或设置一个值,该值指示 MediaElement 是否将在暂停状态下为查找操作更新帧。
        public bool ScrubbingEnabled { get; set; }

        //获取或设置 MediaElement 上的媒体源。
        public Uri Source { get; set; }

        //获取或设置媒体的速率。
        public double SpeedRatio { get; set; }

        //获取或设置一个 Stretch 值,该值描述 MediaElement 如何填充目标矩形。
        public System.Windows.Media.Stretch Stretch { get; set; }

        //获取或设置一个值,该值确定有关应用于图像的缩放的限制。
        public System.Windows.Controls.StretchDirection StretchDirection { get; set; }

        //获取或设置媒体的卸载行为 MediaState。
        public System.Windows.Controls.MediaState UnloadedBehavior { get; set; }

        //获取或设置媒体的音量。
        public double Volume { get; set; }

        //排列 MediaElement 控件并调整其大小。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize);

        //关闭媒体。
        public void Close();

        //更新 DesiredSize 的 MediaElement。 此方法由父 UIElement 调用。 这是第一个布局处理过程。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize);

        //创建并返回此 AutomationPeer 的 MediaElement 对象。
        protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer();

        //在 DrawingContext 控件的呈现处理过程中,绘制 MediaElement 对象的内容。
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext);

        //在当前位置暂停媒体。
        public void Pause();

        //从当前位置播放媒体。
        public void Play();

        //停止并重置媒体使其从头播放。
        public void Stop();

        //在媒体缓冲结束时发生。
        public event System.Windows.RoutedEventHandler BufferingEnded;

        //在媒体缓冲开始时发生。
        public event System.Windows.RoutedEventHandler BufferingStarted;

        //在媒体结束时发生。
        public event System.Windows.RoutedEventHandler MediaEnded;

        //当遇到错误时发生。
        public event EventHandler<System.Windows.ExceptionRoutedEventArgs> MediaFailed;

        //在完成媒体加载时发生。
        public event System.Windows.RoutedEventHandler MediaOpened;

        //在媒体中遇到脚本命令时发生。
        public event EventHandler<System.Windows.MediaScriptCommandRoutedEventArgs> ScriptCommand;

        //此类型或成员支持 Windows Presentation Foundation (WPF) 基础结构,并且不应在代码中直接使用。
        Uri System.Windows.Markup.IUriContext.BaseUri { get; set; }

    }

2.8.11 Page

封装一页可由 Windows Internet Explorer、NavigationWindow 和 Frame 导航到和承载的内容。

Page 封装可导航的内容页,其中包含以下关键成员:

可以使用标记,标记和隐藏代码或代码来定义页面。页面是打包内容进行导航的首选方式,原因如下:

可以从WindowNavigationWindowFrame或从浏览器托管页面。要托管,页面可以是:

一个应用程序通常具有两个或多个页面,可以使用以下机制在两个页面之间进行导航:

有关使用页面函数(PageFunction <T>)的结构化导航的信息,请参见《结构化导航概述》和《导航拓扑概述》

此控件的依赖项属性可以由控件的默认样式设置。如果使用默认样式设置属性,则当控件出现在应用程序中时,该属性可能会从其默认值更改。默认样式由运行应用程序时使用的桌面主题确定。有关更多信息,请参见默认WPF主题

    public class Page : FrameworkElement, IWindowService, IAddChild
    {
        public static readonly System.Windows.DependencyProperty BackgroundProperty;
        public static readonly System.Windows.DependencyProperty ContentProperty;
        public static readonly System.Windows.DependencyProperty FontFamilyProperty;
        public static readonly System.Windows.DependencyProperty FontSizeProperty;
        public static readonly System.Windows.DependencyProperty ForegroundProperty;
        public static readonly System.Windows.DependencyProperty KeepAliveProperty;
        public static readonly System.Windows.DependencyProperty TemplateProperty;
        public static readonly System.Windows.DependencyProperty TitleProperty;

        //获取或设置 Page 的背景。
        public System.Windows.Media.Brush Background { get; set; }

        //获取或设置 Page 的内容。
        public object Content { get; set; }

        //获取或设置指定字体系列的名称。
        public System.Windows.Media.FontFamily FontFamily { get; set; }

        //获取或设置字号。
        public double FontSize { get; set; }

        //获取或设置 Page 的前景。
        public System.Windows.Media.Brush Foreground { get; set; }

        //获取或设置一个值,该值指示是否在导航历史记录中保留 Page 实例。
        public bool KeepAlive { get; set; }

        //返回 Page 的逻辑子元素的枚举器。
        protected internal override System.Collections.IEnumerator LogicalChildren { get; }

        //获取页的宿主用来管理导航的导航服务。
        public System.Windows.Navigation.NavigationService NavigationService { get; }

        //获取或设置一个值,该值指示 NavigationWindow Microsoft Internet Explorer 6 上的导航 UI 是否可见。
        public bool ShowsNavigationUI { get; set; }

        //获取或设置 Page 的控件模板。
        public System.Windows.Controls.ControlTemplate Template { get; set; }

        //获取或设置 Page 的标题。
        public string Title { get; set; }

        //获取或设置 Window 的宿主 NavigationWindow 或 Page 的高度。
        public double WindowHeight { get; set; }

        //获取或设置 Window 的宿主 NavigationWindow 或 Page 的标题。
        public string WindowTitle { get; set; }

        //获取或设置 Window 的宿主 NavigationWindow 或 Page 的宽度。
        public double WindowWidth { get; set; }

        //排列 Page 的内容(子元素)
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size arrangeBounds);

        //测量 Page 的子元素。
        protected override System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //当 Page 的模板更改时调用。
        protected virtual void OnTemplateChanged(System.Windows.Controls.ControlTemplate oldTemplate, System.Windows.Controls.ControlTemplate newTemplate);

        //当 Page 的父项更改时调用。
        protected internal override sealed void OnVisualParentChanged(System.Windows.DependencyObject oldParent);

        //允许派生类确定 ShowsNavigationUI 属性的序列化行为。
        public bool ShouldSerializeShowsNavigationUI();

        //允许派生类确定 Title 属性的序列化行为。
        public bool ShouldSerializeTitle();

        //允许派生类确定 WindowHeight 属性的序列化行为。
        public bool ShouldSerializeWindowHeight();

        //允许派生类确定 WindowTitle 属性的序列化行为。
        public bool ShouldSerializeWindowTitle();

        //允许派生类确定 WindowWidth 属性的序列化行为。
        public bool ShouldSerializeWindowWidth();

        //有关此成员的说明,请参见 AddChild(Object)。
        void IAddChild.AddChild(object obj);

        //有关此成员的说明,请参见 AddText(String)。
        void IAddChild.AddText(string str);

    }

2.8.12 RowDefinition

定义将应用于 Grid 元素的特定于行的属性。

必须 RowDefinition 为中的每行设置 Grid 。 设置行特定时 RowDefinition ,可以为每行分配唯一的大小调整属性。

若要使用代码设置一组 RowDefinition 元素,请将添加 RowDefinition 到 RowDefinitionCollection 。

RowDefinition类只公开高度属性。 若要在中设置 width 属性 Grid ,请创建的实例 ColumnDefinition 。

    public class RowDefinition : DefinitionBase
    {
        public static readonly System.Windows.DependencyProperty MaxHeightProperty;
        public static readonly System.Windows.DependencyProperty MinHeightProperty;
        public static readonly System.Windows.DependencyProperty HeightProperty;

        //获取一个值,该值表示计算所得的 RowDefinition 高度。
        public double ActualHeight { get; }

        //获取 RowDefinition 元素的计算所得的高度,或设置由 RowDefinition 定义的行的 GridLength 值。
        public System.Windows.GridLength Height { get; set; }

        //获取或设置一个值,该值表示 RowDefinition 的最大高度。
        public double MaxHeight { get; set; }

        //获取或设置一个值,该值表示 RowDefinition 的允许的最低高度。
        public double MinHeight { get; set; }

        //获取一个值,该值表示此 RowDefinition 的偏移量值。
        public double Offset { get; }
    }

2.8.13 ScrollContentPresenter

显示 ScrollViewer 控件的内容。

ScrollContentPresenter类为控件的各种组件提供样式支持 ScrollViewer 。 有关中的滚动区域的信息 ScrollViewer ,请参阅 IScrollInfo 。

    public sealed class ScrollContentPresenter : ContentPresenter, IScrollInfo
    {
        public static readonly System.Windows.DependencyProperty CanContentScrollProperty;

        //获取要在其上呈现装饰器的 AdornerLayer。
        public System.Windows.Documents.AdornerLayer AdornerLayer { get; }

        //指示如果内容支持 IScrollInfo,则是否应当允许内容控制滚动。
        public bool CanContentScroll { get; set; }

        //获取或设置一个值,该值指示是否可以在水平轴上滚动。
        public bool CanHorizontallyScroll { get; set; }

        //获取或设置一个值,该值指示是否可以在垂直轴上滚动。
        public bool CanVerticallyScroll { get; set; }

        //获取范围的垂直大小。
        public double ExtentHeight { get; }

        //获取此盘区的水平大小。
        public double ExtentWidth { get; }

        //获取滚动内容的水平偏移量。
        public double HorizontalOffset { get; }

        //获取或设置控制滚动行为的 ScrollViewer 元素。
        public System.Windows.Controls.ScrollViewer ScrollOwner { get; set; }

        //获取滚动内容的垂直偏移量。
        public double VerticalOffset { get; }

        //获取此内容的视区的垂直大小。
        public double ViewportHeight { get; }

        //获取此内容的视区的水平大小。
        public double ViewportWidth { get; }

        //将 ScrollContentPresenter 内容向下滚动一行。
        public void LineDown();

        //将 ScrollContentPresenter 内容向左滚动预先确定的量。
        public void LineLeft();

        //将 ScrollContentPresenter 内容向右滚动预先确定的量。
        public void LineRight();

        //向上滚动一行 ScrollContentPresenter 内容。
        public void LineUp();

        //强制内容滚动,直至 Visual 对象的坐标空间可见。
        public System.Windows.Rect MakeVisible(System.Windows.Media.Visual visual, System.Windows.Rect rectangle);

        //用户单击鼠标的滚轮按钮后向下滚动内容。
        public void MouseWheelDown();

        //用户单击鼠标的滚轮按钮后向左滚动内容。
        public void MouseWheelLeft();

        //用户单击了鼠标的滚轮按钮之后向右滚动内容。
        public void MouseWheelRight();

        //用户单击鼠标的滚轮按钮后向上滚动内容。
        public void MouseWheelUp();

        //当内部进程或应用程序调用 ApplyTemplate() 时调用,用于生成当前模板的可视化树。
        public override void OnApplyTemplate();

        //在内容中向下滚动一页。
        public void PageDown();

        //在内容中向左滚动一页。
        public void PageLeft();

        //向右滚动一页的内容。
        public void PageRight();

        //在内容中向上滚动一页。
        public void PageUp();

        //设置水平偏移量。
        public void SetHorizontalOffset(double offset);

        //设置垂直偏移量。
        public void SetVerticalOffset(double offset);
    }

2.8.14 TextBlock

提供一个轻型控件,用于显示少量流内容。

Remarks

TextBlock可以在其 Text 属性或 Inline 流内容元素中包含字符串,如在Inlines属性内的 Bold 、 Hyperlink 和 InlineUIContainer

TextBlock设计为轻巧的,专门用于将流内容的一小部分集成到用户界面(UI)中。 TextBlock针对单行显示进行了优化,并为显示多达几行的内容提供了良好的性能。

对于需要显示多行内容的场景,TextBlock并未进行优化。在这种情况下,就性能而言,将FlowDocument与适当的查看控件结合使用是比TextBlock更好的选择。在TextBlock之后,FlowDocumentScrollViewer是显示流内容的下一个最轻量的控件,它仅提供具有最少UI的滚动内容区域。 FlowDocumentPageViewer针对流内容的“一次页面”查看模式进行了优化。最后,FlowDocumentReader支持用于查看流内容的最丰富的设置功能,但重量相应地更大。

使用TextAlignment属性可以在TextBlock中水平对齐文本。使用Horizo​​ntalAlignmentVerticalAlignment属性在页面布局内对齐TextBlock

   public class TextBlock : FrameworkElement, IContentHost, IAddChildInternal, IAddChild, IServiceProvider
    {
        public static readonly System.Windows.DependencyProperty BackgroundProperty;
        public static readonly System.Windows.DependencyProperty BaselineOffsetProperty;
        public static readonly System.Windows.DependencyProperty FontFamilyProperty;
        public static readonly System.Windows.DependencyProperty FontSizeProperty;
        public static readonly System.Windows.DependencyProperty FontStretchProperty;
        public static readonly System.Windows.DependencyProperty FontStyleProperty;
        public static readonly System.Windows.DependencyProperty FontWeightProperty;
        public static readonly System.Windows.DependencyProperty ForegroundProperty;
        public static readonly System.Windows.DependencyProperty IsHyphenationEnabledProperty;
        public static readonly System.Windows.DependencyProperty LineHeightProperty;
        public static readonly System.Windows.DependencyProperty LineStackingStrategyProperty;
        public static readonly System.Windows.DependencyProperty PaddingProperty;
        public static readonly System.Windows.DependencyProperty TextAlignmentProperty;
        public static readonly System.Windows.DependencyProperty TextDecorationsProperty;
        public static readonly System.Windows.DependencyProperty TextEffectsProperty;
        public static readonly System.Windows.DependencyProperty TextProperty;
        public static readonly System.Windows.DependencyProperty TextTrimmingProperty;
        public static readonly System.Windows.DependencyProperty TextWrappingProperty;

        //获取或设置要用于填充内容区域背景的 Brush。
        public System.Windows.Media.Brush Background { get; set; }

        //获取或设置文本的每个行相对于基线的偏移量。
        public double BaselineOffset { get; set; }

        //获取一个 LineBreakCondition,它指示内容应当如何在当前元素之后进行分行。
        public System.Windows.LineBreakCondition BreakAfter { get; }

        //获取一个 LineBreakCondition,它指示内容应当如何在当前元素之前进行分行。
        public System.Windows.LineBreakCondition BreakBefore { get; }

        //获取一个指向 TextPointer 中内容的末尾的 TextBlock。
        public System.Windows.Documents.TextPointer ContentEnd { get; }

        //获取一个指向 TextPointer 中内容的开始位置的 TextBlock。
        public System.Windows.Documents.TextPointer ContentStart { get; }

        //获取或设置 TextBlock 的首选最常用字体系列。
        [System.Windows.Localizability(System.Windows.LocalizationCategory.Font)]
        public System.Windows.Media.FontFamily FontFamily { get; set; }

        //获取或设置 TextBlock 的顶级字号。
        public double FontSize { get; set; }

        //获取或设置 TextBlock 的常用字体拉伸特征。
        public System.Windows.FontStretch FontStretch { get; set; }

        //获取或设置 TextBlock 的顶级字体样式。
        public System.Windows.FontStyle FontStyle { get; set; }

        //获取或设置 TextBlock 的顶级字体粗细。
        public System.Windows.FontWeight FontWeight { get; set; }

        //获取或设置要应用到 TextBlock 的文本内容的 Brush。
        public System.Windows.Media.Brush Foreground { get; set; }

        //获取一个可用于迭代此 TextBlock 承载的元素的枚举数。
        protected virtual System.Collections.Generic.IEnumerator<System.Windows.IInputElement> HostedElementsCore { get; }

        //获取包含顶级 Inline 元素的 InlineCollection,前者构成 TextBlock 的内容。
        public System.Windows.Documents.InlineCollection Inlines { get; }

        //获取或设置一个值,该值指示是否启用文字的自动断字功能。
        public bool IsHyphenationEnabled { get; set; }

        //获取或设置各行内容的高度。
        public double LineHeight { get; set; }

        //获取或设置用于为 TextBlock 中的每行文本确定行框的机制。
        public System.Windows.LineStackingStrategy LineStackingStrategy { get; set; }

        //获取一个可循环访问 TextBlock 的逻辑子级的枚举器。
        protected internal override System.Collections.IEnumerator LogicalChildren { get; }

        //获取或设置一个值,该值指示内容区域的边界之间填充空间的宽度,以及由 TextBlock 显示的内容。
        public System.Windows.Thickness Padding { get; set; }

        //获取或设置 TextBlock 的文本内容。
        public string Text { get; set; }

        //获取或设置一个值,该值指示文本内容的水平对齐方式。
        public System.Windows.TextAlignment TextAlignment { get; set; }

        //获取或设置 TextDecorationCollection,它包含应用于 TextBlock 的文本的效果。
        public System.Windows.TextDecorationCollection TextDecorations { get; set; }

        //获取或设置要应用于此元素中的文本内容的效果。
        public System.Windows.Media.TextEffectCollection TextEffects { get; set; }

        //获取或设置在内容超出内容区域时要采用的文本剪裁行为。
        public System.Windows.TextTrimming TextTrimming { get; set; }

        //获取或设置 TextBlock 对文本进行换行的方式。
        public System.Windows.TextWrapping TextWrapping { get; set; }

        //获取此元素的内容的当前有效版式变体。
        public System.Windows.Documents.Typography Typography { get; }

        //获取 Visual 所承载的 TextBlock 子项的数目。
        protected override int VisualChildrenCount { get; }

        //定位子元素并确定 TextBlock 的大小。
        protected override sealed System.Windows.Size ArrangeOverride(System.Windows.Size arrangeSize);

        //返回指定的依赖对象的 BaselineOffset 附加属性值。
        public static double GetBaselineOffset(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 FontFamilyProperty 附加属性值。
        public static System.Windows.Media.FontFamily GetFontFamily(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 FontSize 附加属性值。
        public static double GetFontSize(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 FontStretch 附加属性值。
        public static System.Windows.FontStretch GetFontStretch(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 FontStyle 附加属性值。
        public static System.Windows.FontStyle GetFontStyle(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 FontWeight 附加属性值。
        public static System.Windows.FontWeight GetFontWeight(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 Foreground 附加属性值。
        public static System.Windows.Media.Brush GetForeground(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 LineHeight 附加属性值。
        public static double GetLineHeight(System.Windows.DependencyObject element);

        //返回指定的依赖对象的 LineStackingStrategy 附加属性值。
        public static System.Windows.LineStackingStrategy GetLineStackingStrategy(System.Windows.DependencyObject element);

        //返回指向最靠近指定 TextPointer 的位置的 Point。
        public System.Windows.Documents.TextPointer GetPositionFromPoint(System.Windows.Point point, bool snapToText);

        //返回指定的 ContentElement 的边框的只读集合。
        protected virtual System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Rect> GetRectanglesCore(System.Windows.ContentElement child);

        //返回指定的依赖对象的 TextAlignment 附加属性值。
        public static System.Windows.TextAlignment GetTextAlignment(System.Windows.DependencyObject element);

        //返回指定索引位置处的 Visual 子项。
        protected override System.Windows.Media.Visual GetVisualChild(int index);

        //返回指定 PointHitTestResult 的 PointHitTestParameters。
        protected override sealed System.Windows.Media.HitTestResult HitTestCore(System.Windows.Media.PointHitTestParameters hitTestParameters);

        //返回 IInputElement 内指定 Point 处的 TextBlock。
        protected virtual System.Windows.IInputElement InputHitTestCore(System.Windows.Point point);

        //调用以重新测量 TextBlock。
        protected override sealed System.Windows.Size MeasureOverride(System.Windows.Size constraint);

        //当派生自 UIElement 的子元素更改其 DesiredSize 时调用。
        protected virtual void OnChildDesiredSizeChangedCore(System.Windows.UIElement child);

        //创建并返回此 AutomationPeer 的 TextBlock 对象。
        protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer();

        //当一个或多个托管依赖属性的值发生更改时调用。
        protected override sealed void OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e);

        //呈现 TextBlock 的内容。
        protected override sealed void OnRender(System.Windows.Media.DrawingContext ctx);

        //设置指定的依赖对象上的 BaselineOffset 附加属性值。
        public static void SetBaselineOffset(System.Windows.DependencyObject element, double value);

        //设置指定的依赖对象上的 FontFamily 附加属性值。
        public static void SetFontFamily(System.Windows.DependencyObject element, System.Windows.Media.FontFamily value);

        //设置指定的依赖对象上的 FontSize 附加属性值。
        public static void SetFontSize(System.Windows.DependencyObject element, double value);

        //设置指定的依赖对象上的 FontStretch 附加属性值。
        public static void SetFontStretch(System.Windows.DependencyObject element, System.Windows.FontStretch value);

        //设置指定的依赖对象上的 FontStyle 附加属性值。
        public static void SetFontStyle(System.Windows.DependencyObject element, System.Windows.FontStyle value);

        //设置指定的依赖对象上的 FontWeight 附加属性值。
        public static void SetFontWeight(System.Windows.DependencyObject element, System.Windows.FontWeight value);

        //设置指定的依赖对象上的 Foreground 附加属性值。
        public static void SetForeground(System.Windows.DependencyObject element, System.Windows.Media.Brush value);

        //设置指定的依赖对象上的 LineHeight 附加属性值。
        public static void SetLineHeight(System.Windows.DependencyObject element, double value);

        //设置指定的依赖对象上的 LineStackingStrategy 附加属性值。
        public static void SetLineStackingStrategy(System.Windows.DependencyObject element, System.Windows.LineStackingStrategy value);

        //设置指定的依赖对象上的 TextAlignment 附加属性值。
        public static void SetTextAlignment(System.Windows.DependencyObject element, System.Windows.TextAlignment value);

        //返回一个值,该值指示在序列化 BaselineOffset 对象期间,是否应对 TextBlock 属性的有效值进行序列化。
        public bool ShouldSerializeBaselineOffset();

        //返回一个值,该值指示在序列化 Inlines 对象期间,是否应对 TextBlock 属性的有效值进行序列化。
        public bool ShouldSerializeInlines(System.Windows.Markup.XamlDesignerSerializationManager manager);

        //返回一个值,该值指示在序列化 Text 对象期间,是否应对 TextBlock 属性的有效值进行序列化。
        public bool ShouldSerializeText();

        //此方法支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。
        object IServiceProvider.GetService(Type serviceType);

        //此方法支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。 改用类型安全的 GetRectanglesCore(ContentElement) 方法。
        System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Rect> IContentHost.GetRectangles(System.Windows.ContentElement child);

        //此类型或成员支持 Windows Presentation Foundation (WPF) 基础结构,并且不应在代码中直接使用。 请改用类型安全的 HostedElementsCore 属性。
        System.Collections.Generic.IEnumerator<System.Windows.IInputElement> System.Windows.IContentHost.HostedElements { get; }

        //此方法支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。 改用类型安全的 InputHitTestCore(Point) 方法。
        System.Windows.IInputElement IContentHost.InputHitTest(System.Windows.Point point);

        //此方法支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。 改用类型安全的 OnChildDesiredSizeChangedCore(UIElement) 方法。
        void IContentHost.OnChildDesiredSizeChanged(System.Windows.UIElement child);

        //此成员支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。
        void IAddChild.AddChild(object value);

        //此成员支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。
        void IAddChild.AddText(string text);
    }

2.8.15 Viewport3D

呈现 Viewport3D 元素的 2-D 布局范围内包含的 3-D 内容。

Viewport3D元素呈现三维内容,同时提供与 FrameworkElement 对象(包括二维布局、剪辑和输入事件)一致的功能。

当将此元素作为诸如Canvas之类的布局元素的内容包括在内时,通过设置Viewport3DHeightWidth属性(从FrameworkElement继承)来指定Viewport3D的大小。

 

 

Viewport3D通过将2-D命中测试点扩展到3-D射线中,将2-D命中测试扩展到3-D场景中。调用HitTest方法以返回有关命中视觉,模型,网格和相交点的详细命中结果信息。

在Microsoft Windows XP上,如果显示颜色质量未设置为32位或16位,则Viewport3D可能无法按预期方式呈现。

    public class Viewport3D : FrameworkElement, IAddChild
    {
        public static readonly System.Windows.DependencyProperty CameraProperty;
        public static readonly System.Windows.DependencyProperty ChildrenProperty;

        //获取或设置将的三维内容投影到的二维图面的照相机对象 Viewport3D Viewport3D 。
        public System.Windows.Media.Media3D.Camera Camera { get; set; }

        //获取 Viewport3D 的 Visual3D 子集合。
        public System.Windows.Media.Media3D.Visual3DCollection Children { get; }

        //获取一个整数,该整数表示 Visual 的 Children 集合中 Visual3D 对象的数目。
        protected override int VisualChildrenCount { get; }

        //使 Viewport3D 排列其可视内容以适应指定大小。
        protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize);

        //获取位于 Visual 的 Children 集合中指定位置的 Viewport3D。
        protected override System.Windows.Media.Visual GetVisualChild(int index);

        //为此 Viewport3DAutomationPeer 创建并返回一个 Viewport3D 对象。
        protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer();

        //此成员支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。
        void IAddChild.AddChild(object value);

        //此成员支持 Windows Presentation Foundation (WPF) 基础结构,不应在代码中直接使用。
        void IAddChild.AddText(string text);
     }

2.8.16 WebBrowser

承载 HTML 文档并在其之间导航。 启用 WPF 托管代码和 HTML 脚本之间的互操作性。

WebBrowser控件提供了以下功能:

导航: Source 、 Navigate 、 NavigateToStream 、 NavigateToString 和 Refresh 。

导航生存期: Navigating 、 Navigated 和 LoadCompleted 。

导航日志记录: CanGoBack 、 GoBack 、 CanGoForward 和 GoForward 。

WPF/HTML 互操作性: InvokeScript 和 ObjectForScripting 、和 Document 。

WebBrowser 由承载的 WPF 应用程序的安全约束绑定 WebBrowser :

 注意

WebBrowser控件在内部实例化本机 WebBrowser ActiveX 控件。 WPF 通过将功能控件应用于 WebBrowser ActiveX 控件来启用安全功能。 应用的功能控件在 Xbap 和独立应用程序方面有所不同。 某些应用程序应该应用其他功能控制,以防止恶意内容运行。 有关详细信息,请参阅 Security (WPF) 和 WebBrowser 控件概述和教程中的 "WebBrowser 控件和功能控件" 一节。

    public sealed class WebBrowser : ActiveXHost
    {
        //获取指示是否存在要向后定位到的文档。
        public bool CanGoBack { get; }

        //获取指示是否存在要向前定位到的文档。
        public bool CanGoForward { get; }

        //获取表示所承载的 HTML 页的文档对象。
        public object Document { get; }

        //获取或设置公共类的一个实例,该实例由主机应用程序实现且可由寄宿文档的脚本访问。
        public object ObjectForScripting { get; set; }

        //获取或设置 Uri 中承载的当前文档的 WebBrowser。
        public Uri Source { get; set; }

        //向后定位到前一文档(如果存在)。
        public void GoBack();

        //向前定位到下一个 HTML 文档(如果有)。
        public void GoForward();

        //执行在当前加载的文档中定义的脚本函数。
        public object InvokeScript(string scriptName);
        public object InvokeScript(string scriptName, params object[] args);

        //异步导航到位于指定 Uri 处的文档。
        public void Navigate(string source, string targetFrameName, byte[] postData, string additionalHeaders);
        public void Navigate(Uri source, string targetFrameName, byte[] postData, string additionalHeaders);
        public void Navigate(string source);
        public void Navigate(Uri source);

        //异步导航到文档内容所在的 Stream。
        public void NavigateToStream(System.IO.Stream stream);

        //异步导航到文档内容所在的 String。
        public void NavigateToString(string text);

        //重载当前页。
        public void Refresh();
        public void Refresh(bool noCache);

        //要导航到的文档完成下载时发生。
        public event System.Windows.Navigation.LoadCompletedEventHandler LoadCompleted;

        //定位到要导航到的文档并开始下载时发生。
        public event System.Windows.Navigation.NavigatedEventHandler Navigated;

        //正好在导航到某个文档之前发生。
        public event System.Windows.Navigation.NavigatingCancelEventHandler Navigating;
    }

参考微软MSDN

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值