You will have to add that new Diagram to the view's visual tree somehow. E.g. one possible way to do that would be binding a ScrollViewer's Content property to the model's Diagram property. However, that would allow only a single instance of the view to be used, because the same diagram cannot be added to more than one parent scroll viewer.
If you need to display more than one view, you could use the DiagramView class for that. Its Diagram property can be set to a shared Diagram instance displayed by many DiagramViews. However at this time it isn't a dependency property and you cannot bind it. Instead, you could derive from DiagramView to define a bindable property:
public class BoundDiagramView : DiagramView
{
public static DependencyProperty DiagramModelProperty = DependencyProperty.Register(
"DiagramModel",
typeof(Diagram),
typeof(BoundDiagramView),
new PropertyMetadata(OnModelChanged));
public Diagram DiagramModel
{
get { return (Diagram)GetValue(DiagramModelProperty); }
set { SetValue(DiagramModelProperty, value); }
}
private static void OnModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var instance = (BoundDiagramView)d;
instance.Diagram = (Diagram)e.NewValue;
}
}
Now you can add a BoundDiagramView object to your view Xaml:
<local:BoundDiagramView DiagramModel="{Binding DiagramModel}" />
Where DiagramModel is also the name of the Diagram property in your model class:
public Diagram DiagramModel
{
get { return diagramModel; }
set
{
diagramModel = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("DiagramModel"));
}
}
I hope that helps,
Stoyan