Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>That's better.</p> <p>This is how I would solve it. Not too much explanation since best explanation is code ;).</p> <pre><code>public class IncrementalLoadingCollection&lt;T&gt; : ObservableCollection&lt;T&gt;, ISupportIncrementalLoading { // todo; write a lot of magic here.(VIEW) } // IN PCL public abstract class PortableFactory { private static PortableFactory _factory; public static PortableFactory Current { get { if (_factory == null) { throw new InvalidOperationException(); } return _factory; } set { _factory = value; } } protected PortableFactory() { // note we auto-set current here, // which saves an extra step for the caller Current = this; } public abstract IList&lt;T&gt; GetIncrementalCollection&lt;T&gt;(); } // IN XAML APP public partial class App : Application { private PortableFactory _pf = new WPFPortableViewFactory(); private class WPFPortableViewFactory : PortableFactory { public override IList&lt;T&gt; GetIncrementalCollection&lt;T&gt;() { return new IncrementalLoadingCollection&lt;T&gt;(); } } } // IN VIEWMODEL public class ViewModel { public IList&lt;Car&gt; Cars { get; set; } public ViewModel() { Cars = PortableFactory.Current.GetIncrementalCollection&lt;Car&gt;(); } } </code></pre> <p>the code was taken here(with few modifications): <a href="http://blogs.msdn.com/b/sburke/archive/2011/02/03/using-observablecollection-with-the-portable-library-tools-ctp.aspx" rel="nofollow">http://blogs.msdn.com/b/sburke/archive/2011/02/03/using-observablecollection-with-the-portable-library-tools-ctp.aspx</a></p>
 

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