At runtime I am creating a WPF control. It can be any WPF Control.
I want to find out whether this WPF Control, IS A CONTAINER CONTROL.
i.e. can this control can embed/contain another control.
Does there exist any Attribute through which the above can be achieved?
e.g. a label, panel, groupBox can contain other control like button, but textBOX cant.
In WPF there are a few base classes that controls extend from.
ContentControl: Most controls extend from this because most controls can store some type of single content within them.ItemsControl: These are types of collection controls, which contain a collection of content within them.Panel: These are special controls for layouts. They implement theArrangeOverrideandMeasureOverridemethods to measure/arrange the children controls within them. Most of them also expose attached properties for best use.That being said, you would typically want to use the
isoperator to check if your control inherits from what you intend it to. You can be specific or general, but typically you want to be as general as possible. I’m not sure what you meant by “container”, which is why I listed the three (3) typical base controls that could contain other controls. For example: