What is the “best” (or most commonly used) approach when associating a complex class with a user control for reuse?
I am trying to create several reusable libraries for classes, and I'm not sure which approach I should use. Example. I want to create an address library that defines the class and address (with properties Line1, Line2, etc.), Validation logic and AddressControl, which acts as a viewer / editor with associated fields for each property.
When used, I can have a client class with parameters BillingAddress, DeliveryAddress, and I would like to bind them in my client in this way:
<addressLib:AddressControl [xxx]="{Binding BillingAddress}" />
So the question is, what did I put in XXX?
I initially thought about creating a DependencyProperty 'Address' in the control:
<addressLib:AddressControl Address="{Binding BillingAddress}" />
But now I think that I could just use the existing DataContext property?
<addressLib:AddressControl DataContext="{Binding BillingAddress}" />
Is this a better approach? Are there any problems, for example. updates or problems with NotifyPropertyChange?
Many thanks for your help!
source
share