PackagePart.CreateRelationship Method (Uri, TargetMode, String)
Assembly: WindowsBase (in windowsbase.dll)
public PackageRelationship CreateRelationship ( Uri targetUri, TargetMode targetMode, string relationshipType )
public PackageRelationship CreateRelationship ( Uri targetUri, TargetMode targetMode, String relationshipType )
public function CreateRelationship ( targetUri : Uri, targetMode : TargetMode, relationshipType : String ) : PackageRelationship
The of the target part.
The role of the relationship.
Return ValueThe part-level relationship between this PackagePart to the target PackagePart or external resource.
The part has been deleted.
targetUri or relationshipType is a null reference (Nothing in Visual Basic).
The targetMode parameter is not a valid TargetMode enumeration value.
The part identified by the targetUri is a relationship (the target of a relationship cannot be another relationship).
targetMode is specified as Internal but targetUri is an absolute external URI.
The package is read-only (a new relationship cannot be added).
A part-level relationship defines an association between this part and a target part or resource. A part-level relationship can be one of two forms.
Between a source PackagePart to a target PackagePart inside the Package.
Between a source PackagePart to a target resource outside the package.
In a part-relationship the source part is considered the "owner" of the relationship. When the source part is deleted, all the relationships owned by the part are also deleted. The process of creating or deleting the relationship does not physically alter the target part or resource in any way.
The CreateRelationship method does not physically change either the source part, or the target part or resource in any way.
The target of a relationship cannot be another relationship.
If targetMode is specified as Internal, targetUri must be a relative URI that is formed in accordance with the RFC 3986 Uniform Resource Identifier (URI) Generic Syntax specification. The internal relative URI can be either an absolute path that starts with a forward slash ("/") character such as "/page1.xaml" or "/images/picture4.jpg", or a relative path such as "../imagespicture1.jpg" that resolves against the package root ("/") as the base URI.
If targetMode is specified as External, targetUri can be either an absolute or relative URI formed in accordance with the RFC 3986 Uniform Resource Identifier (URI) Generic Syntax specification. "http://www.microsoft.com/page2.xml" is an example of an absolute URI that references an external target resource "page2.xml". "images/picture1.jpg" is an example of a relative URI that also references an external target resource "1.jpg" but which resolves against the URI of the package itself.
relationshipType must be a URI that is formed according to the RFC 3986 Uniform Resource Identifier (URI) Generic Syntax specification. Different package types can define different part-level relationship types. The following table shows the part-level relationshipType URIs defined for documents that conform to the Open XML Paper Specification (XPS).
XPS Document Part-Level Relationship
Relationship Type URI
Digital Signature Definitions
For more information about package relationships see section 1.3 of the Open Packaging Conventions (OPC) specification available for download at http://go.microsoft.com/fwlink/?LinkID=71255.
For more information about XPS documents see the Open XML Paper Specification (XPS) available for download at http://go.microsoft.com/fwlink/?LinkID=67000.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Other ResourcesThe Addressing Model of the Open Packaging Conventions
Pack URIs in Windows Presentation Foundation
Open Packaging Conventions Specification
The Addressing Model of the Open Packaging Conventions
Open Packaging Conventions Specification