OnWindowRestored()

View as Markdown

Definition

Called when the window is restored from a workspace, which is called after OnWindowCreated(). This method is used to recall any custom XElement data from the workspace by referencing a window. Please also see OnWindowSaved() for information on how to store custom XElement data when a window is saved.

Method Return Value

This method does not return a value.

Syntax

OnWindowRestored(Window window, XElement element)

Parameters

ParameterDescription
windowA Window object which is being restored from a workspace
elementThe XElement object representing the workspace being restored

Examples

1protected override void OnWindowRestored(Window window, XElement element)
2{
3 Print("OnWindowRestored for " + window.GetHashCode());
4
5 // locate the worksapces "SampleAddOn" elemenet which was created and saved earlier using the OnWindowSaved() method
6 XElement sampleAddOnElement = element.Element("SampleAddOn");
7
8 // do not do anything if that element does not exist
9 if (sampleAddOnElement == null)
10 return;
11
12 // loop through all the contents of the "SampleAddOn" element
13 foreach (XElement content in sampleAddOnElement.Elements())
14 {
15 // find the "ButtonState" content, restore it's value and set that as our tracked buttonState
16 if (content.Name == "ButtonState")
17 {
18 bool buttonState = false;
19 bool.TryParse(content.Value, out buttonState);
20 continue;
21 }
22 //Parse additional elements here
23 }
24
25 //Don't forget to call the base OnWindowRestored method after you're done.
26 base.OnWindowRestored(window, element);