lundi 29 juin 2015

Multiple Inheritance - want to extend a class that extends Panel, but I also want to extend StackPanel

I have a control, ShrinkingTabPanel, that proportionally resizes tabs as they're added so they all fit (like Chrome). However, it extends Panel, and this doesn't work with the functionality I'm trying to achieve - the width of the ShrinkingTabPanel doesn't increase with number of items like it should.

When I changed the class to extend StackPanel instead, that was the exact functionality I needed.

However, ShrinkingTabPanel is a control that is part of a library that we bought, and it's usually discouraged to change imported source code.

I know multiple inheritance isn't allowed in C#, but is there any way I can "effectively" extend ShrinkingTabPanel and StackPanel in one class?

The first solution I thought of was to make a new class that extended StackPanel, and to just call ShrinkingTabPanel.ArrangeOverride() and ShrinkingTabPanel.MeasureOverride() within the respective methods, effectively extending ShrinkingTabPanel. But I'm not sure if that's the smartest idea.

Aucun commentaire:

Enregistrer un commentaire