Example #1
0
    private static void OnBehaviorsChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
    {
        if (e.NewValue is BehaviorCreatorCollection == false)
        {
            return;
        }
        BehaviorCreatorCollection newBehaviorCollection = e.NewValue as BehaviorCreatorCollection;
        BehaviorCollection        behaviorCollection    = Interaction.GetBehaviors(depObj);

        behaviorCollection.Clear();
        foreach (IBehaviorCreator behavior in newBehaviorCollection)
        {
            behaviorCollection.Add(behavior.Create());
        }
    }
 /// <summary>
 /// Sets behavior collection to tree view.
 /// </summary>
 /// <param name="treeView">Tree View.</param>
 /// <param name="value">Behavior collection.</param>
 public static void SetBehaviors(TreeView treeView, BehaviorCreatorCollection value)
 {
     treeView.SetValue(BehaviorsProperty, value);
 }