I have a constructor whit a parameter p1 which has following specifications:
- p1 must inherit from UserControl
- p1 must realize Interface MyInterface
Example:
public class ClassA: UserControl, MyInterface
{ ... }
Anyone an idea how I can define the method.
The constructor looks like this:
public MyClass(UserControl uc) : base(uc)
{
// access to MyInterface-Methods
}
The base class (which is from a third party dll) requires a UserControl, I need access to the MyInterface Methods.
Thanks in advance,
rhe1980
You do it by declaring an abstract base class:
And declare your constructor argument of that type. The client code now must derive from BaseControl and implement the interface.
Not so sure that will work well in the WPF designer, I know that it won’t work in the Winforms designer, it needs to be able to construct an instance of the base class. Nor does a generic work, for the same reason. In which case you must resort to a runtime check: