Created
April 17, 2015 14:43
-
-
Save julesx/acd0e1c03f9d90bd6094 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows; | |
namespace PageableListBox | |
{ | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
DataContext = new MainWindowVm(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="PageableListBox.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<ListBox ItemsSource="{Binding Items}" /> | |
</Window> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Linq; | |
using DynamicData; | |
using DynamicData.Binding; | |
using DynamicData.Controllers; | |
namespace PageableListBox | |
{ | |
public class MainWindowVm | |
{ | |
public ObservableCollectionExtended<MyVm> Items { get; set; } | |
public MainWindowVm() | |
{ | |
var myCache = new SourceCache<MyVm, string>(myobject => myobject.Id); | |
//this is an extension of observable collection optimised for dynamic data | |
Items = new ObservableCollectionExtended<MyVm>(); | |
//these controllers enable dynamically changing filter, sort and page | |
var pageController = new PageController(); | |
var filterController = new FilterController<MyVm>(); | |
var sortController = new SortController<MyVm>(SortExpressionComparer<MyVm>.Ascending(t => t.Id)); | |
var mySubscription = myCache.Connect() | |
.Filter(filterController) | |
.Sort(sortController) | |
.Page(pageController) | |
.ObserveOnDispatcher() | |
.Bind(Items) | |
.Subscribe(); | |
myCache.AddOrUpdate(new MyVm("1")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment