I have a UserControl
that have a few child UserControl
's and those UserControl
's have child UserControl's.
Consider this:
MainUserControl
TabControl
TabItem
UserControl
UserControl
UserControl : ISomeInterface
TabItem
UserControl
UserControl
UserControl : ISomeInterface
TabItem
UserControl
UserControl
UserControl : ISomeInterface
TabItem
UserControl
UserControl
UserControl : ISomeInterface
This is what i have so far, but finds no ISomeInterface
:
PropertyInfo[] properties = MainUserControl.GetType().GetProperties();
foreach (PropertyInfo property in properties)
{
if (typeof(ISomeInterface).IsAssignableFrom(property.PropertyType))
{
property.GetType().InvokeMember("SomeMethod", BindingFlags.InvokeMethod, null, null, null);
}
}
Is it possible so find all the child UserControl
's from MainUserControl
that implement ISomeInterface
via reflection and call a method(void SomeMethod()
) on that interface?