# DocumentStack class

Namespace: [Grasshopper2.UI.Canvas](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.ui.canvas.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public sealed class DocumentStack
```

A stack of nested documents. A [DocumentBag](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentbag.md) contains a collection of [DocumentStack](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack.md) objects. Each stack contains a root document which is (ideally) associated with a *.ghz file. Then when nested documents are opened, they are pushed onto the stack. When editing a cluster, inside a cluster inside the root document, the stack will contain three documents, the innermost one being at the head.

## Constructors

- [DocumentStack](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/ctor.md)

## Properties

- [ContainsUnsaved](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/containsunsaved.md): Gets whether any of the documents in this stack currently have unsaved state.
- [Count](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/count.md): Gets the number of documents in this stack.
- [Documents](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/documents.md): Enumerate over all documentsm starting with the head.
- [Head](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/head.md): Gets the current head of this stack. This changes when child documents are pushed or popped.
- [Root](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/root.md): Gets the root document of this stack. This never changes.

## Methods

- [RegisterAcceptHandler](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/registeraccepthandler.md): Add a callback to a specific document for acceptance handling.
- [RegisterRejectHandler](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.documentstack/registerrejecthandler.md): Add a callback to a specific document for rejection handling.
