In This Article

RecentDocumentManager Class

Provides a manager for a recent documents list.

public class RecentDocumentManager : DependencyObject
Inheritance:
object object

Constructors

RecentDocumentManager()

Initializes an instance of the class.

public RecentDocumentManager()

Properties

Documents

The collection of IDocumentReference objects that are being managed.

public DocumentReferenceCollection Documents { get; }

Property Value

DocumentReferenceCollection

Remarks

Add/remove the document references to be managed via this collection. The FilteredDocuments provides a sorted read-only representation of this collection.

FilteredDocuments

The read-only collection of filtered documents that should be used for a recent documents list.

public ReadOnlyDocumentReferenceCollection FilteredDocuments { get; }

Property Value

ReadOnlyDocumentReferenceCollection

Remarks

The collection sorts the contained documents by date/time and pinned states and returns up to MaxFilteredDocumentCount documents.

MaxDocumentCount

The maximum number of documents to store in the Documents collection.

public int MaxDocumentCount { get; set; }

Property Value

int:

The default value is 30.

Remarks

This collection is how many documents total are being tracked.

MaxFilteredDocumentCount

The maximum number of documents to return in the FilteredDocuments collection.

public int MaxFilteredDocumentCount { get; set; }

Property Value

int:

The default value is 16.

Methods

Deserialize(string)

Deserializes the Documents collection from the data in an XML string.

public void Deserialize(string xml)
Parameter Type Description
xml string

The XML string containing data.

Remarks

The XML string must have been created by a previous call to Serialize().

GetDocumentReference(Uri)

Returns an existing IDocumentReference from the Documents collection, if any, that matches the specified System.Uri.

public IDocumentReference? GetDocumentReference(Uri location)
Parameter Type Description
location Uri

The System.Uri to search for.

Returns

IDocumentReference

GetIndex(DependencyObject)

Gets the value of the Index attached property for the specified object.

public static int GetIndex(DependencyObject obj)
Parameter Type Description
obj DependencyObject

The object from which the property value is read.

Returns

int

NotifyDocumentOpened(Uri, string?, object?)

Provides a helper method for easily updating an existing document reference's last-opened date/time. If no existing document reference with the specified System.Uri exists, a new DocumentReference is created.

public IDocumentReference NotifyDocumentOpened(Uri location, string? name = null, object? tag = null)
Parameter Type Description
location Uri

A System.Uri indicating the location of the document.

name string

The name of the document.

tag object

An arbitrary object value that can be used to store custom information about this document reference.

Returns

IDocumentReference:

The IDocumentReference that was updated or created.

RebindFilteredDocuments()

Rebinds the FilteredDocuments collection.

public void RebindFilteredDocuments()

Remarks

The FilteredDocuments collection is automatically re-bound when the Documents collection is changed. However if you update the last-opened date/time or pinned flag for an IDocumentReference, you must call this method manually to rebind the FilteredDocuments collection.

Serialize()

Serializes the Documents collection to an XML string.

public string Serialize()

Returns

string:

The XML string that contains the serialized data.

Remarks

Use the Deserialize(string) method to load the serialized data later.

SetIndex(DependencyObject, int)

Sets the value of the Index attached property to the specified object.

public static void SetIndex(DependencyObject obj, int value)
Parameter Type Description
obj DependencyObject

The object to which the attached property is written.

value int

The value to set.

Fields

IndexProperty

Defines the Index property.

public static readonly DependencyProperty IndexProperty

MaxDocumentCountProperty

Defines the MaxDocumentCount property.

public static readonly DependencyProperty MaxDocumentCountProperty

MaxFilteredDocumentCountProperty

Defines the MaxFilteredDocumentCount property.

public static readonly DependencyProperty MaxFilteredDocumentCountProperty

Extension Methods