This question is locked. New answers and comments are not allowed.
Hi,
im trying to modify the default OrgChart example. I have a subclass wich is loading the defaut organization.xml from web. Once the download and XML-parsing is complete, a PropertyChanged event is fired. Unfortunately, all shapes are stacked in the upper left corner and the connection lines are messed up: The most outer nodes have no connections any more and the other node connections are all directing in the left upper corner. Same problems with the default demo code (embedded XML) when im trying to set the graph source from the event handler. Everything is fine when im moving the populateGraphSource-calls back to the ViewModel-Constructor. Tested with the demo XML-code.
My modified viewmodel looks like this:
im trying to modify the default OrgChart example. I have a subclass wich is loading the defaut organization.xml from web. Once the download and XML-parsing is complete, a PropertyChanged event is fired. Unfortunately, all shapes are stacked in the upper left corner and the connection lines are messed up: The most outer nodes have no connections any more and the other node connections are all directing in the left upper corner. Same problems with the default demo code (embedded XML) when im trying to set the graph source from the event handler. Everything is fine when im moving the populateGraphSource-calls back to the ViewModel-Constructor. Tested with the demo XML-code.
My modified viewmodel looks like this:
public
OrgChartViewModel()
{
this
.ToggleVisibilityCommand =
new
DelegateCommand(
this
.ExecuteToggleVisibilityCommand,
this
.CanExecuteToggleVisibilityCommand);
_Repository.PropertyChanged +=
new
System.ComponentModel.PropertyChangedEventHandler(_Repository_PropertyChanged);
}
void
_Repository_PropertyChanged(
object
sender, System.ComponentModel.PropertyChangedEventArgs e)
{
switch
(e.PropertyName)
{
case
"OrganizationXML"
:
this
.GraphSource =
new
GraphSource();
this
.HierarchicalDataSource =
new
ObservableCollection<Node>();
this
.PopulateWithData();
this
.GraphSource.PopulateGraphSource(
this
.HierarchicalDataSource[0]);
break
;
default
:
break
;
}
}
private
void
PopulateWithData()
{
foreach
(XElement element
in
_Repository.OrganizationXML.Elements(
"Node"
))
{
Node node =
this
.CreateNode(element);
node.Children.AddRange(
this
.GetSubNodes(element));
this
.HierarchicalDataSource.Add(node);
}
}