PackageRelationship 类


表示源 PackagePackagePart 与可以为 PackagePart 或外部资源的目标对象之间的关联。Represents an association between a source Package or PackagePart, and a target object which can be a PackagePart or external resource.

public ref class PackageRelationship
public class PackageRelationship
type PackageRelationship = class
Public Class PackageRelationship


PackageRelationship 定义PackagePackagePart目标PackagePart 或外部资源之间的关联。A PackageRelationship defines an association between a source Package or PackagePart to a target PackagePart or external resource. 源对象被视为关系的 "所有者"。The source object is considered the "owner" of the relationship.

PackageRelationship 类没有公共构造函数;相反,将使用两种 Create 方法:The PackageRelationship class has no public constructor; instead, two Create methods are used:

Package.CreateRelationshipPackage.CreateRelationship 创建从包到指定部分或外部资源的 "包级别" 关系。Creates a "package-level" relationship-from a package to a specified part or external resource.
PackagePart.CreateRelationshipPackagePart.CreateRelationship 创建 "部分级" 关系-从一个部分到另一个部分或外部资源。Creates a "part-level" relationship-from one part to another part or external resource.

源包或部分由关系的 SourceUri 属性标识。The source package or part is identified by the SourceUri property of the relationship. 目标部分或外部资源由关系的 TargetUri 属性标识。The target part or external resource is identified by the TargetUri property of the relationship.

创建或删除关系不会以任何方式影响源对象或目标对象。Creating or deleting a relationship does not affect the source or target objects in any way.

如果删除源对象,则也将删除该对象拥有的所有关系。If a source object is deleted, all relationships owned by the object are also deleted.

关系允许在文档中和文档之间导航。Relationships enable navigation both in a document and between documents. 关系还支持文档对象模型服务,例如在打印时将 PrintTicket 链接到特定的文档元素。Relationships also support document object model services, such as linking a PrintTicket to specific document elements when printing.

有关 PackageRelationship 元素的详细信息,请参阅开放打包约定规范中可供下载的的 "关系" 1.3 部分。For more information about PackageRelationship elements see Section 1.3 "Relationships" in the Open Packaging Conventions specification available for download at



获取标识关系的字符串。Gets a string that identifies the relationship.


获取包含此关系的 PackageGets the Package that contains this relationship.


获取关系的限定类型名称。Gets the qualified type name of the relationship.


获取拥有关系的包或部分的 URI。Gets the URI of the package or part that owns the relationship.


获取一个值,该值指示关系的目标是 InternalExternal 指向 PackageGets a value that indicates whether the target of the relationship is Internal or External to the Package.


获取关系的目标资源的 URI。Gets the URI of the target resource of the relationship.



确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)