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 節 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.


取得值,指出關聯性目標是 PackageInternalExternalGets 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)