I have a generic type class called
public class ScrollClippingViewer<T> where T : Control, IFScrollClippingItem
This class will handle different kinds of UserControls that also inherit IFScrollClippingItem. It will store the UserControls in a list, and makes sure they are displayed in order in a ScrollViewer.
What I would like is that a UserControl would have a property or method in the interface that creates the possibility to communicate back to the ScrollClippingViewer; My problem rises because the ScrollClippingViewer is a generic type class and I dont know how to put this in the interface:
public interface IFScrollClippingItem
{
// This does not work
ScrollClippingViewer<T> refScrollClippingViewer { get; set; }
// This neither
void SetScrollClippingViewer(ScrollClippingViewer<T> argRefScrollClippingViewer);
}
You can have templated method in your interface, like this:
but it doesn't seem to be good idea, because template type
Thas no connection with interface, so when implementing interface you'll write something like:In this method you'll be able to work with
argRefScrollClippingViewerpassed, but you won't be able to save it to a typed property, as long as there can't be property of typeScrollClippingViewer<T>.I would recommend you to introduce some interface:
IScrollClippingViewerwhich will be implemented byScrollClippingViewerand will provide needed functions forIFScrollClippingIteminstances.For example: