>
>
>
V3048. WPF: several Dependency Properti…


V3048. WPF: several Dependency Properties are registered with a same name within the owner type.

The analyzer detected a possible error related to dependency property registration. Two dependency properties were registered under the same name within one class.

class A : DependencyObject
{
public static readonly DependencyProperty CurrentTimeProperty =
  DependencyProperty.Register("CurrentTime",....);

public static readonly DependencyProperty OtherProperty =
  DependencyProperty.Register("CurrentTime",....); 
....

Because of copy-paste, the OtherProperty dependency property was registered under the name 'CurrentTime' instead of 'Other' as intended by the developer.

A correct way to register the dependency properties in the code above is as follows:

public static readonly DependencyProperty CurrentTimeProperty =
  DependencyProperty.Register("CurrentTime",....);

public static readonly DependencyProperty OtherProperty =
  DependencyProperty.Register("Other",....);