Category Archives: Silverlight

TechDays 2011: Rx talk, slides and source code

As promised, here is a blog post which shares source code and slides for the Rx talk I gave during last TechDays in Paris. I animated this session with my co-worker Charlotte and with Mitsu.

Download slides here.
Download source code here.

Demo1: Drag’n’drop in a WPF application

The goal was to implement a basic drag’n’drop functionality in a WPF application. The Rx query looks like the following:

var query = from mouseDown in this.image.GetMouseLeftButtonDownObservable()
            let downPosition = mouseDown.EventArgs.GetPosition(this)
            let rect = new Rect(downPosition.X - 10, downPosition.Y - 10, 20, 20)
            let delta = mouseDown.EventArgs.GetPosition(this.image)
            from mouseMove in this.GetMouseMoveObservable()
                .Select(ea => ea.EventArgs.GetPosition(this))
                .SkipWhile(p => rect.Contains(p))
                .DoOnce(p => this.onMouseEnter.Begin(this.image))
                .Select(p => p.Offset(delta))
                .TakeUntil(this.GetMouseLeftButtonUpObservable())
                .Finally(() => this.onMouseLeave.Begin(this.image))
            select mouseMove;

query.Subscribe(p => this.image.SetPosition(p));

Demo2: online Twitter search and Bing map geolocalization

This time, the goal was to query Twitter asynchronously and to geolocalize the associated Tweets. The Rx query:

this.textbox.GetTextChangedObservable()
    .DistinctUntilChanged((ea) => this.textbox.Text)
    .Throttle(TimeSpan.FromMilliseconds(300))
    .ObserveOnDispatcher()
    .Do(ea => this.ShowLoadingIndicator())
    .Select(ea => TweeterHelper.Search(this.textbox.Text))
    .Switch()
    .ObserveOn(Scheduler.Dispatcher)
    .Select(page => TweeterHelper.ParseTwitterSearch(page))
    .Subscribe((tweets) =>
                    {
                        this.HideLoadingIndicator();
                        this.listbox.ItemsSource = tweets;

                        TweeterHelper.LocalizeTweets(this.map, tweets);
                    });

Demo3: using the accelerometer in a Windows Phone 7 application

The last demo was about the usage of the accelerometer in a Windows Phone 7 application. Here is the relevant Rx query:

private void MoveEllipse(IObservable accelerationObservable)
{
    accelerationObservable
        .SlidingBuffer(2)
        .Select(accCouple => new Acceleration(accCouple.First(), accCouple.Last()))
        .ObserveOnDispatcher()
        .Do(acc => this.textBlock.Text = acc.ToString())
        .Scan(new Point(x0, y0), (point, acc) => point.Move(acc).ClipTo(horizontalInterval, verticaInterval))
        .Subscribe(p => this.ellipse.SetCenter(p));
}

Doing this session was a really great experience ! I’d like to thank Charlotte and Mitsu for doing it with me. Also, I’d like to thank all users who came to the presentation !

TechDays 2011: Rx talk in Paris

During the next 3 days, the “Palais des Congrès” in Paris will hosting the TechDays 2011. For the very first time, I’ll have the chance to be part of it as a speaker for a talk about Rx (Reactive Extensions).

The session will take place in room 241, tomorrow Thursday 8, from 1pm to 2pm. Here is the link to the session’s description (in French).

I’ll share presentation slides and source code by the end of the week đŸ™‚

MVVM Framework Explorer update and top MVVM Frameworks

A couple of days ago I received an email from Geert van Horrik, a developer working on a new MVVM Framework called Catel. Geert asked me to update my MVVM Framework Explorer app in order to include his new framework. Here is the resulting updated app (click to launch):

Besides adding this new framework, I updated the download count for each framework, which allowed me to do some statistics. Here are the download progression for the most popular MVVM frameworks between July 2010 and January 2011:

Framework July 2010 January 2011 Progression
Calcium 7486 9963 33%
Caliburn 27012 36392 35%
Cinch 9865 15206 54%
CoreMVVM 3373 4419 31%
MEFedMVVM 905 2074 129%
MVVM Foundation 5759 7656 33%
MVVM Helpers 674 1571 133%
MVVM Light 11601 30111 160%
NitoMVVM 446 1098 146%
nRoute 7638 13724 80%
Onyx 2027 2195 8%
WAF 12255 30673 150%

Top progression during the last 6 months:

  1. MVVM Light (by Laurent Bugnion): +160%
  2. MVVM Helpers (by Mark Smith): +133%
  3. MEFedMVVM (by Marlon Grech): +129%
  4. WAF (by Jurgen Berchtel): +150%

Top downloaded frameworks:

  1. Caliburn (by Rob Eisenberg): +36 000 downloads
  2. MVVM Light (by Laurent Bugnion): +30 000 downloads
  3. WAF (by Jurgen Berchtel): +30 000 downloads

Congratulations to their respective authors.

Calcium 7486 9963 33%
Caliburn 27012 36392 35%
Cinch 9865 15206 54%
CoreMVVM 3373 4419 31%
MEFedMVVM 905 2074 129%
MVVM Foundation 5759 7656 33%
MVVM Helpers 674 1571 133%
MVVM Light 11601 30111 160%
NitoMVVM 446 1098 146%
nRoute 7638 13724 80%
Onyx 2027 2195 8%
WAF 12255 30673 150%