SD13
SD13

Reputation: 119

Dependency in WPF custom control

I am writing a WPF custom control extended from Listbox. In the control I have a border which I need to size with some specific logic. This logic is embedded in another class(different library) i.e. this custom control has a dependency. So

1.Should I inject this dependency by writing a Dependency property in the Control and then assigning this property the object which encapsulated the logic or

2.Custom control should not be dependent on any library in this case I have to duplicate the logic.

Upvotes: 1

Views: 254

Answers (1)

Sheridan
Sheridan

Reputation: 69985

I believe that you can answer your own question... imagine this scenario: You go with option 1. Now what does your CustomControl do if a user of the control does not supply that property? I could be wrong, but it seems as though you would still need to provide a default implementation of your functionality in this instance... which could point to your second option being more straight forward.

Upvotes: 1

Related Questions