SilverlightShow: Using Reactive Extensions in Silverlight Comments Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples Argotic Syndication Framework 2008.0.2.0, en-US (Emil Stoychev) RE: Using Reactive Extensions in Silverlight Great article. I learnt more from spending twenty minutes reading your article than from spending five hours watching the ching the Channel 9 Rx videos. Those Channel 9 guys could learn a lot about how to teach new concepts from YOU !! RichardS Sun, 31 Oct 2010 16:06:50 GMT RE: Using Reactive Extensions in Silverlight Thanks for this great post, watched some of the chn9 vidoes but didnt get the point of Rx this did a much better job. I wish i found this post before i saw the chn9 videos! then they probably would have made more sense! Mads Lee Jensen Fri, 21 May 2010 09:51:05 GMT RE: Using Reactive Extensions in Silverlight <em>This comment has been removed, because of inappropriate content.</em> Bell End Thu, 01 Apr 2010 13:00:12 GMT RE: Using Reactive Extensions in Silverlight <p>Hi Tim,</p> <p>Another possible way, to do drag and drop is to use mouse offsets instead of mouse deltas. For example, the code that I am using in the article could be changed to this:</p> <p >var mouseDown = from evnt in Observable.FromEvent<MouseButtonEventArgs>( image, "MouseLeftButtonDown" )<br />                 select evnt.EventArgs.GetPosition( image );<br /> var mouseUp = Observable.FromEvent<MouseButtonEventArgs>( image, "MouseLeftButtonUp" );<br /> var mouseMove = from evnt in Observable.FromEvent<MouseEventArgs>( image, "MouseMove" )<br />                 select evnt.EventArgs.GetPosition( this );<br /> <br /> var query = from offset in mouseDown<br />             from position in mouseMove.TakeUntil( mouseUp )<br />             select new<br />             {<br />                 X = position.X - offset.X,<br />                 Y = position.Y - offset.Y<br />             };<br /> <br /> query.Subscribe(<br />     point =><br />     {<br />         Canvas.SetLeft( image, point.X );<br />         Canvas.SetTop( image, point.Y );<br />     } );</p> <p> </p> <p> </p> ppopadiyn Thu, 25 Mar 2010 12:09:22 GMT RE: Using Reactive Extensions in Silverlight <p>Great article! For drag and drop operations you ought to call CaptureMouse and ReleaseMouseCapture right? I'm not sure what the best way to accomplish this is but one way that I got to work was:</p> <span style="font-family: consolas; font-size: 13px;"><span style="font-family: consolas; font-size: 13px;"> <p> </p> </span> <p> </p> </span> <p><span style="font-family: consolas; color: #0000ff; font-size: 13px;">from</span><span style="font-family: consolas; font-size: 13px;"> pos </span><span style="font-family: consolas; color: #0000ff; font-size: 13px;">in</span><span style="font-family: consolas; font-size: 13px;"> mouseMove.SkipUntil(mouseLeftButtonDown.Do((o) => this.CaptureMouse())). <p> </p> <p>TakeUntil(mouseLeftButtonUp.Do((o) => this.ReleaseMouseCapture()))</p> </span></p> Tim Greenfield Thu, 25 Mar 2010 00:44:09 GMT RE: Using Reactive Extensions in Silverlight <p>Great article!  Thanks for sharing.  By the way, after I read your article, I played around with a way to cut down on the amount of code needed to subscribe and combine multiple IObservables.  Check out my blog post:</p> <p><a href=""></a></p> <p>Thanks!</p> Bobby Diaz Thu, 11 Mar 2010 10:32:46 GMT RE: Using Reactive Extensions in Silverlight <p>@Keith, thanks for tip</p> <p>@Florim, you won't have to wait too long, the next post is comming the next week ( RX + Web services ).</p> ppopadiyn Sun, 07 Mar 2010 21:52:12 GMT RE: Using Reactive Extensions in Silverlight <span title="Postim shume interesant, dhe po RX do te jet shume me interesant nese do te kete me shume postime si ky." class="short_text" id="result_box" style="background-color: #ebeff9; font-size: 24px;"></span>  Very interesting post, and RX will be more interesting for me if will be more posts like this. Florim Maxhuni Sun, 07 Mar 2010 15:35:34 GMT RE: Using Reactive Extensions in Silverlight <p>One tip for "chatty" events like MouseMove is to use Throttle() to only capture one event per time interval (every 100ms, for example).</p> <p>Cheers ~<br /> Keith</p> Keith Dahlby Sat, 06 Mar 2010 17:54:07 GMT RE: Using Reactive Extensions in Silverlight <p>I've looked at this stuff 6 ways to Sunday, but this is the FIRST article that made it make any sense to me.</p> <p>GREAT Stuff!!!</p> Fallon Massey Sat, 06 Mar 2010 10:16:06 GMT RE: Using Reactive Extensions in Silverlight A killer demo would be to have a duplex WCF service push notifications from the server to a silverlight background thread, then have the observable stuff update the UI. Donald Sat, 06 Mar 2010 03:30:25 GMT RE: Using Reactive Extensions in Silverlight <p>I'm feel led astray by the words. I'm expecting that if I make something observable it will be observed... even if I add something later. If I subscribe it should do some work until I unsubscribe.  Maybe some clarification in this area would help.  It seems that the event stuff is the true observation/subscription work.  </p> <p></p> Donald Sat, 06 Mar 2010 03:02:47 GMT RE: Using Reactive Extensions in Silverlight <p>Hi Donald</p> <p>Straight to first question. I beleive <em>products.Add("Test")</em> will no longer work, when the observable sequence ends (the <em>Completed</em> event is raised). What you need to do is to write something like this:</p> <p>IObservable<string> observable = Observable.Return<string>( "Test" );<br /> observable.Subscribe<string>(<br />     p =><br />     {<br />         lbObservable.Items.Add( p );<br />     } );</p> <p>The second question (about the web services) is pretty interesting, and this is common issue for Silverlight. I'll try to prepare a small demo and will update the article.</p> <p>@<span id="ctl00_cphMiddle_ContentPlaceHolderContent_itemComments_dlstComments_ctl04_lblCommentAuthor">miantosca</span> , thanks for the nice words.</p> ppopadiyn Fri, 05 Mar 2010 20:00:01 GMT RE: Using Reactive Extensions in Silverlight great article - watched the ch9 videos a while ago but this article did a better job of explaining how <br /> you might use it so simplify otherwise very complex problems. miantosca Fri, 05 Mar 2010 15:15:16 GMT RE: Using Reactive Extensions in Silverlight By the way, great article.. cleared up alot.  I got notthing out of the ch9 videos. Donald Fri, 05 Mar 2010 09:31:45 GMT RE: Using Reactive Extensions in Silverlight <p>I'm still confused on some aspects of this. I thought that I could click a button to products.Add("Test") and it would automatically be added to the list since it was being 'observed'.  I even tried moving the products and observable to a high scope so they would go out of scope.  I guess this is not what I want.<br /> Would be nice to see how I could add to a list on a background thread data that comes from a web service and see the new data added to added to say a list control.  I think it would be good for notifications.</p> <p>I tried running the calculation with 10000 digits. During that the drag drop was too slow to work well.</p> Donald Fri, 05 Mar 2010 09:07:44 GMT