Building a WPF custom control to act as wrapper for a third party control.

Hi all let me share with you a problem I’m facing…

My goal is to isolate the most possible the dependencies that we have on a specific third party control (DataGrid), so if we later decide to change to another control, we would only have  to modify our custom control and everything else in the application would continue to work perfectly.

I think that, with Winforms, it would be a nice approach. With WPF I’m not so sure…

The problem that I’m seeing relates to customizing the custom control appearance. When implementing my custom control I would provide a default appearance in the custom control library generic theme. But then I would like to give the chance to my application designers to customize the custom control appearance. I think the problem is right there.

It seems to me that my application designers, when creating the styling for my custom control, would have to target the third party control, thus ruining my ultimate goal which was to minimize the references to the third party control.

I’m I thinking correctly?

I would be grateful if you can bring some light to my mind.

2 thoughts on “Building a WPF custom control to act as wrapper for a third party control.

  1. Hi Rui, it’s a very interesting and common problem.

    From my point of view, what you need to do is to replicate the properties you may need in your own control. (“replicate” isn’t the most precise word, it like abstract what is specific for the view you are creating)

    You theme should be made aginst you “public interface”, that is, your custom control, and it should propagate the values to the real control.

    For example, if your control is expandible, you may need an Enum with {Overview, Detail} triggering the right commands in the inner control.

    What do you think?

  2. Rui Silva says:

    Hi Leonardo, thank for taking time to think about it.

    For basic controls I agree with you. but if you imagine a more complex control that are built upon other custom controls, if I wanted to customize these smaller components I will need to target them.

    If you are interested, you can follow a discussin that is happening on this in the WPF Forum: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2510378&SiteID=1

    Thanks again.

Leave a comment