Note that there are some explanatory texts on larger screens.

plurals
  1. POReactive Extensions (Rx) + MVVM =?
    text
    copied!<p>One of the main examples being used to explain the power of Reactive Extensions (Rx) is combining existing mouse events into a new 'event' representing deltas during mouse drag:</p> <pre><code>var mouseMoves = from mm in mainCanvas.GetMouseMove() let location = mm.EventArgs.GetPosition(mainCanvas) select new { location.X, location.Y}; var mouseDiffs = mouseMoves .Skip(1) .Zip(mouseMoves, (l, r) =&gt; new {X1 = l.X, Y1 = l.Y, X2 = r.X, Y2 = r.Y}); var mouseDrag = from _ in mainCanvas.GetMouseLeftButtonDown() from md in mouseDiffs.Until( mainCanvas.GetMouseLeftButtonUp()) select md; </code></pre> <p>Source: <a href="http://codebetter.com/blogs/matthew.podwysocki/archive/2009/11/12/introduction-to-the-reactive-framework-part-iii.aspx" rel="noreferrer" title="Introduction to the Reactive Framework Part III">Matthew Podwysocki's Introduction to the Reactive Framework series</a>.</p> <p>In MVVM I generally strive to keep my .xaml.cs file as empty as possible and one way of hooking up events from the view with commands in the viewmodel purely in markup is using a behavior:</p> <pre><code>&lt;Button Content="Click Me"&gt; &lt;Behaviors:Events.Commands&gt; &lt;Behaviors:EventCommandCollection&gt; &lt;Behaviors:EventCommand CommandName="MouseEnterCommand" EventName="MouseEnter" /&gt; &lt;Behaviors:EventCommand CommandName="MouseLeaveCommand" EventName="MouseLeave" /&gt; &lt;Behaviors:EventCommand CommandName="ClickCommand" EventName="Click" /&gt; &lt;/Behaviors:EventCommandCollection&gt; &lt;/Behaviors:Events.Commands&gt; &lt;/Button&gt; </code></pre> <p>Source: <a href="http://geekswithblogs.net/HouseOfBilz/archive/2009/08/27/adventures-in-mvvm-ndash-binding-commands-to-any-event.aspx" rel="noreferrer" title="Adventures in MVVM – Binding Commands to ANY Event">Brian Genisio</a>.</p> <p>The Reactive Framework seems to be more geared towards the traditional MVC pattern where a controller knows the view and can reference its events directly.</p> <p>But, I want to both have my cake and eat it!</p> <p>How would you combine these two patterns?</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