Binding Example

This is the first in a series of real world dynamic data examples.

Lets’s assume I have a data  which is exposed via a service.

 public interface IPersonService
      IObservableCache<Person, PersonKey> Cache { get; }

and I want to bind the data to a screen. In dynamic data it is done like this.

 //this is a simple extension of observable collection which comes as part of the package
 var collection = new ObservableCollectionExtended<Person>();
 //Dynamic data is an extension of reactive so subscribe at the end of the chain
 var loader = personService.Cache.Connect()

The binding will always reflect the data in the cache (and in the stated sort order).  That was easy so let’s extend this so we can apply a filter. This is also easy.

var loader = personService.Cache.Connect().Filter(p=>p.Age>50) 

or use a filter controller which allows the filter to be changed any time.

 //create a filter controller 
 var filterController = new FilterController<Person>();
 //filter can be changed any time by applying the following method

 var loader = personService.Cache.Connect().Filter(filterController)

And that is that.  We can filter, sort and bind changeable data with very little code.


4 thoughts on “Binding Example

  1. Please don’t use var, when it is so importand to understand what the real return type is when a method like Connect() is called


  2. Thanks for sharing this but I don’t understand where can we find this FilterController that you’re using here, it’s not in any of the GitHub repos. You used it in several blog posts and it looks real interesting, I think it makes Filter method much more versatile but I must be missing something as the full source is nowhere to be found. Either way, thank you for your contributions!


    • Filter controller was removed a few years ago. It was replaced with an overload of Filter which accepts an observable predicate. The examples in dynamic trade have been updated to use the newer methodology.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s