I define Dependency Property for the A class. However, I can query the value of that property in an instance of B. Why?
To illustrate, look a this code (WPF):
using System.Windows;
namespace Sample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var propDefinedForA = DependencyProperty.Register("SomeProperty", typeof(int), typeof(A), new PropertyMetadata(defaultValue: 10));
var b = new B();
var value = b.GetValue(propDefinedForA);
}
}
public class A: DependencyObject
{
}
public class B: DependencyObject
{
}
}
After the execution of this code, the value is 10. Why is this even possible? I haven't defined the DP for the B class, but for A.
What's the reason of this behavior?