Note that the DependencyProperty attached property, not the binding property
First look at a hypothesis,
How to extend a member of a class without modifying a class (inheritance is not possible)
This is not possible in the traditional OO design, but in NET3.0 (c#3.0,vb.net9.0) provides an extension method to implement this function
Look at the following example:
Scene: I often have to use the results of the number 2, how to easily achieve
class Program
{
static void Main(string[] args)
{
double v1 = 123;
double p1 = v1.zzzzz();
System.Console.WriteLine(p1);
//--
double p2=(1234567890.123).zzzzz();
System.Console.WriteLine(p2);
}
}
static class myExtension
{
public static double zzzzz(this double d)
{
return d/2 ;
}
}
This is the extension method that adds the [Zzzzz] method to [double] without modifying the structure.
That's the way LINQ works.
Method can do that, what about the attribute?
Upgrade the requirements, I think an object in an environment automatically more than a few attributes, in another environment and automatically more than a few other attributes
How to do it,
Let's take a look at Silverlight.
Scene: Provides a container, the container is divided into two rows, into the container in the meaning of the control can set the properties of additional properties [MyTag], [MyTag] Property set to [a] on the left, set to [b] on the right