
[DesignTimeVisible(false)] [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)] [XmlLangProperty("Language")] [UsableDuringInitialization(true)] [RuntimeNameProperty("Name")] [UidProperty("Uid")] [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)] [NameScopeProperty("NameScope", System.Windows.NameScope)] public class PartManager : System.Windows.FrameworkElement
Each Diagram has an instance of this class as its PartManager property. This class maintains a collection of all diagram Nodes and Links, as well as dictionaries mapping model data to Nodes and Links. You can find the Part for a model data object by calling FindNodeForData and FindLinkForData(Object,IDiagramModel). Use FindLinkForData(Object,Object,IDiagramModel) when the model does not support separate link data objects.
If you want to add nodes programmatically, don't call AddNodeForData! You need to add node data to the model by calling Northwoods.GoXam.Model.IDiagramModel.AddNode. That will automatically update all diagrams that are using the model by calling OnModelChanged, which will in turn call AddNodeForData for you. Remember to wrap all changes to a model or to its data in a transaction.
If you want to customize the standard behavior, you can easily override any of its methods and substitute an instance of your custom part manager class for your diagram. public class CustomPartManager : PartManager { protected override String FindCategoryForNode(Object nodedata, IDiagramModel model, bool isgroup, bool islinklabel) { // maybe choose different category here, to dynamically determine the DataTemplate found by FindTemplateForNode } }
and install it with either XAML: <go:Diagram ...> <go:Diagram.PartManager> <local:CustomPartManager /> </go:Diagram.PartManager> </go:Diagram>
or in the initialization of your Diagram control: myDiagram.PartManager = new CustomPartManager();
Although this class inherits from FrameworkElement
in order to support data binding, it is not really a FrameworkElement
or UIElement
! Please ignore all of the properties, methods, and events defined by FrameworkElement
and UIElement
.
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Media.Visual
System.Windows.UIElement
System.Windows.FrameworkElement
Northwoods.GoXam.PartManager