SilverlightShow: Using Reactive Extensions in Silverlight Comments http://www.silverlightshow.net/ Silverlight articles, Silverlight tutorials, Silverlight videos, Silverlight samples SilverlightShow.net http://www.rssboard.org/rss-specification Argotic Syndication Framework 2008.0.2.0, http://www.codeplex.com/Argotic en-US estoychev@completit.com (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 !! http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment4792 RichardS http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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! http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3649 Mads Lee Jensen http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3339 Bell End http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3307 ppopadiyn http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3305 Tim Greenfield http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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="http://blog.bmdiaz.com/archive/2010/03/11/generate-strongly-typed-observable-events-for-the-reactive-extensions-for.aspx">http://blog.bmdiaz.com/archive/2010/03/11/generate-strongly-typed-observable-events-for-the-reactive-extensions-for.aspx</a></p> <p>Thanks!</p> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3208 Bobby Diaz http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3188 ppopadiyn http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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. http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3186 Florim Maxhuni http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3182 Keith Dahlby http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3178 Fallon Massey http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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. http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3177 Donald http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3176 Donald http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3175 ppopadiyn http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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. http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3173 miantosca http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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. http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3170 Donald http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx 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> http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx#comment3169 Donald http://www.silverlightshow.net/items/Using-Reactive-Extensions-in-Silverlight.aspx Fri, 05 Mar 2010 09:07:44 GMT