OnWindowSaved()

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Add On >

OnWindowSaved()

Previous page Return to chapter overview Next page

Definition

Called when the window is saved to a workspace, which is called before OnWindowDestroyed().  This method is used to save any custom XElement data associated with your window.

 

Method Return Value

This method does not return a value

 

Syntax

OnWindowSaved(Window window, XElement element)

 

Parameters

window

A Window object which is being saved to the workspace

element

A XElement object representing the workspace being saved

 

 

Examples

ns

protected override void OnWindowSaved(Window window, XElement element)
{
  Print("OnWindowSaved for " + window.GetHashCode());
 
  // create a new XElement to save the last state of a custom button to the workspace
  XElement xml = new XElement("SampleAddOn", new XElement("ButtonState", true));

 
  // e.g.,
  // <SampleAddOn>
  //  <ButtonState>true</ButtonState>
  // </SampleAddOn>
 
  // add the new element to the workspace which can be restored later
  element.Add(xml);                
 
  //Don't forget to call the base OnWindowSaved method after you've finished your operation.
  base.OnWindowSaved(window, element);
}