if (nodes != null)
nodes.SetTree (tree);
ResetPathData ();
+ if (PopulateOnDemand && !Populated && Expanded.HasValue && Expanded.Value)
+ Populate ();
}
}
public TreeNodeCollection ChildNodes {
get {
if (nodes == null) {
- if (PopulateOnDemand && tree == null)
- return null;
-
nodes = new TreeNodeCollection (this);
if (IsTrackingViewState)
((IStateManager)nodes).TrackViewState();
-
- if (PopulateOnDemand && !Populated) {
- Populated = true;
- Populate ();
- }
}
return nodes;
}
ViewState ["Expanded"] = value;
if (tree != null)
tree.NotifyExpandedChanged (this);
+ if (PopulateOnDemand && !Populated && value.HasValue && value.Value)
+ Populate ();
}
}
internal void Populate ()
{
+ if (tree == null)
+ return;
+
+ Populated = true;
tree.NotifyPopulateRequired (this);
}
bool? value = Expanded;
Expanded = value.HasValue ? !value.Value : true;
#else
- Expanded = !Expanded;
+ Expanded = !Expanded.GetValueOrDefault(false);
#endif
}
internal void SetDirty ()
{
ViewState.SetDirty (true);
+ if (nodes != null)
+ nodes.SetDirty ();
}
public virtual object Clone ()
}
internal bool IsParentNode {
- get { return ChildNodes.Count > 0 && Parent != null; }
+ get { return !IsRootNode && (ChildNodes.Count > 0 || PopulateOnDemand); }
}
internal bool IsLeafNode {
- get { return ChildNodes.Count == 0; }
+ get { return !IsRootNode && ChildNodes.Count == 0 && !PopulateOnDemand; }
}
internal bool IsRootNode {
- get { return ChildNodes.Count > 0 && Parent == null; }
+ get { return Depth == 0; }
}
TreeNodeBinding GetBinding ()