Click here to Skip to main content
15,887,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
From System.Windows.Interactivity.dll:

C#
private static readonly DependencyProperty BehaviorsProperty = DependencyProperty.RegisterAttached("ShadowBehaviors", typeof(BehaviorCollection), typeof(Interaction), new FrameworkPropertyMetadata(new PropertyChangedCallback(Interaction.OnBehaviorsChanged)));

public static BehaviorCollection GetBehaviors(DependencyObject obj)
{
  BehaviorCollection behaviors = (BehaviorCollection) obj.GetValue(BehaviorsProperty);
  if (behaviors == null)
  {
    behaviors = new BehaviorCollection();
    obj.SetValue(BehaviorsProperty, behaviors);
  }
  return behaviors;
}


This behavior doesn't follow the convention since the dependency property is named ShadowBehaviors. Can you explain why, it seems deliberate by Microsoft.
Posted

1 solution

I think they did it because the dependency property is a private one and so they don't need to follow the conventions.

Also to make clear that this property is intended only for internal use.

Did you read the comment of the BehaviorsProperty?

As I only have the german version, here a rough translation:

in summary:
'This property is used as internal backup storage for the property that is attached to the public behaviors.'

in remarks:
'This property is not publicly available. This forces clients to use the methods GetBehaviors and SetBehaviors to access the collection to make sure that the collection is initialized before being used.'

Regards,



Thomas.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900