10 Answers, 1 is accepted
In our Org example we're doing this as you said on size changed event.
private void Diagram_SizeChanged(object sender, SizeChangedEventArgs e)
{
this.orgLayoutAlgorithm.Layout(this.diagram1);
this.diagram1.AutoFit();
}
And it works as expected. Actually you only need to wait for the shapes be measured and have proper sizes. Which in fact should be ready if you hook the RadDiagram.SizeChanged event. Please let me know if it's not. One not very good solution is to delay the layout using Dispatcher, but I think you should be ok with the SizeChanged event. All the best,
Miro Miroslavov
the Telerik team
Unfortunately there isn't such event for the moment. It's something we should solve for Q2, so I created new work item for it. Currently I think that maybe only LayoutUpdated event is suitable for your case. But you should be very careful with it and remove the handler after the initial layout.
We'll let you know if we find a better solution for this scenario.
Miro Miroslavov
the Telerik team
We created a feature request for an event that fires after all shapes are prepared and ready for layout. You can track its progress here.
Regards,Petar Mladenov
the Telerik team
This functionality makes perfect sense. If I open a file containing the diagram and then want to autofit it, when should I do that?
It's been a year since the problem was originally reported :( 18 votes...
We have updated the status of this Feature Request to "Resolved". In Q1 2013 you will be able to use the GraphSourceChanged event which fires when the Shapes are generated and measured. We have added a comment in the PITS item in the Description Section with more information.
Kind regards,Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
GraphSourceChanged is designed to fire when the GraphSource is assigned / re-set. It does not fire when adding removing links/nodes. For this purpose, you can use InternalItems.CollectionChanged or InternalLinks.CollectionChanged:
public
class
Graph : ObservableGraphSourceBase<Link, Node>
{
public
Graph()
{
this
.InternalItems.CollectionChanged += InternalItems_CollectionChanged;
this
.InternalLinks.CollectionChanged += InternalLinks_CollectionChanged;
}
void
InternalLinks_CollectionChanged(
object
sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
throw
new
NotImplementedException();
}
void
InternalItems_CollectionChanged(
object
sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
throw
new
NotImplementedException();
}
}
Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.