System.Windows.Documents 命名 ...


.NET Framework 类库
TextElementEditingBehaviorAttribute 类

更新:2007 年 11 月

指定 RichTextBox 应如何处理自定义文本元素。

命名空间:  System.Windows.Documents
程序集:  PresentationFramework(在 PresentationFramework.dll 中)
用于 XAML 的 XMLNS:http://schemas.microsoft.com/winfx/xaml/presentation

语法

Visual Basic(声明)
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class TextElementEditingBehaviorAttribute _
    Inherits Attribute
Visual Basic (用法)
Dim instance As TextElementEditingBehaviorAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Class)]
public sealed class TextElementEditingBehaviorAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Class)]
public ref class TextElementEditingBehaviorAttribute sealed : public Attribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */
public final class TextElementEditingBehaviorAttribute extends Attribute
JScript
public final class TextElementEditingBehaviorAttribute extends Attribute
XAML 对象元素用法
<TextElementEditingBehaviorAttribute .../>
备注

创建自定义文本元素时,可以使用 TextElementEditingBehaviorAttribute 属性指定应将该元素作为不可分割的单个实体进行处理。 如果将 IsMergeableIsTypographicOnly 属性设置为 false,则当用户编辑 RichTextBox 时,RichTextBox 将保留该元素的边界和内容。 一般来讲,自定义元素的行为与 Hyperlink 的行为类似。 使用此类并将它的两个属性都设置为 false 时,将发生以下行为:

  • 当用户复制和粘贴自定义元素中的部分内容时,不会保留所复制文本的格式。

  • 当用户在自定义元素的内容之前或之后进行键入时,新内容不会获取该自定义元素的格式信息。

  • 用户无法在自定义元素中插入换行符。

创建自定义元素时,若要在将该元素序列化到磁盘或剪贴板时保留自定义元素和属性值,可使用 TextRange..::.Save(Stream, String, Boolean) 方法并将 preserveTextElements 设置为 true

.NET Framework 3.5 版中引入了 TextElementEditingBehaviorAttribute。有关更多信息,请参见 .NET Framework 3.5 体系结构

继承层次结构

System..::.Object
  System..::.Attribute
    System.Windows.Documents..::.TextElementEditingBehaviorAttribute
线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
平台

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.5 SP1、3.0 SP1
另请参见

参考

标记 :


Page view tracker