Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As hyde said, you really would need to separate your behaviour from what your classes <em>are</em>. You said you didn't want to use interfaces; well, I can't think of a way around that. You may have to bite the bullet or do some code duplication.</p> <p>At minimal, you can move the behaviour logic to a separate controlling class and simply feed it some interface that exposes the members needed. Consider the few properties you <em>need</em> for a scrollable UI control (mind you, this is all just whipped off examples, I doubt these types exist as I describe, or these are the actual <em>minimum</em> set needed): </p> <pre><code>public interface ISCrollable { Control Target { get; } ScrollBar Bar { get; } double FullLength { get; } double VisibleLength { get; } } </code></pre> <p>You then can put your scrolling behaviour in a class that attaches that behaviour or works upon an <code>IScrollable</code>:</p> <pre><code>public class Scroller { public Scroller(ISCrollable scrollable) { //attach behaviour scrollable.Bar.OnClick += DoScroll; //and other stuff } } </code></pre> <p>Finally, your <code>ScrollableWidget</code> would be your <code>Control</code> and attach the scrolling behaviour rather than inheriting it:</p> <pre><code>public class ScrollableWidget : Control, INamingContainer, ISCrollable, IWidget { private Scroller ScrollBehaviour; private Widgeter = WidgetBehaviour; public Control Target { get; private set; } public ScrollBar Bar { get; private set; } public double FullLength { get; private set; } public double VisibleLength { get; private set; } public ScrollableWidget() { this.Target = this; this.Bar = CreateScrollBarControl(); this.FullLength = 9001; this.VisibleLength = this.ActualHeight; this.ScrollBehaviour = new Scroller(this); this.WidgetBehaviour = new Widgeter(this); } } </code></pre> <p>So yeah, you're going to want to use interfaces. I don't understand your requirement not to. There are other patterns, such as <a href="http://en.wikipedia.org/wiki/Decorator_pattern" rel="nofollow">Decorator</a>, that may be a better suit than the mess I just posted.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload