Search
VirtualizingDiagram.NodeStyleSelector Property
See Also
 





Gets or sets custom style-selection logic that can be applied to each node.

Namespace: MindFusion.Diagramming.Wpf
Assembly: MindFusion.Diagramming.Wpf

 Syntax

C#  Copy Code

public StyleSelector NodeStyleSelector { get; set; }

Visual Basic  Copy Code

Public Property NodeStyleSelector As StyleSelector

 Property Value

An instance of the System.Windows.Controls.StyleSelector class.

 Remarks

When the selector's SelectStyle method is invoked, its item argument refers to a data item from NodesSource, and the container argument refers to the actual DiagramNode bound to the item.

 Example

The following selector returns one of two styles defined in a Xaml dictionary depending on the type of data item.

C#  Copy Code

class CustomStyleSelector : StyleSelector
{
    public override Style SelectStyle(object item, DependencyObject container)
    {
        ResourceDictionary x = (ResourceDictionary)Application.LoadComponent(
            new Uri("/Application;component/Styles/NodeStyles.xaml", UriKind.Relative));

        FrameworkElement element = container as FrameworkElement;
        element.Resources = x;

        if (type is TaskItem)
            return (Style)element.FindResource("TaskStyle");
        else
            return (Style)element.FindResource("AnnotationStyle");
    }
}

 See Also