Why is the ListViewGroup sealed?

I can subclass ListViewItem and even ListViewItem.ListViewSubItem, but I cannot subclass ListViewGroup.

Why is this?

+2


source to share


2 answers


There is not really an answer as Microsoft will answer "Its by design", many classes are Sealed, which makes development very difficult and in some cases we used Reflector to understand how the class family works and we recreated our own classes to extend the functionality ... One of them was to create validations and error templates, but yes there is no answer to such a question, other than its design.



0


source


The ListViewGroup is sealed because you cannot add or change its functionality. The implementation doesn't work in ListViewGroup

.

ListViewGroup is a friendly wrapper around a native Win32 control. You cannot descend from a new class hoping to add functionality - functionality is not part of the class.




For the same reason that it is ImageList

sealed. If assigned to a list of images ListView

, that list of images should be wrapped around its own ImageList control, which is exactly what the list looks like. You can't go down to ImageList to support alpha blended lists of PNG images - it just won't work.

Classes are closed when there is bad encapsulation and there is no point in downstreaming because you cannot legally change anything.

+2


source







All Articles