SilverlightShow: Paging WCF Ria Services entities in Model-View-ViewModel applications 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: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>This helped me a lot!!</p> <p>I had to apply the fixes suggested by HC and I also had to override the Count() method in my DomainService class as mentioned in:</p> <pre style="font-family: consolas; font-size: 13px; color: black; background: none repeat scroll 0% 0% white;"><span style="color: green;"> http://silverlightfeeds.com/post/2900/WCF_RIA_Services_and_TotalEntitiesCount-1.aspx</span> </pre> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment7338 mateofd http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Thu, 22 Dec 2011 21:49:12 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications Thanks! That post is very-very helpful! http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment5500 ielektronick http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Mon, 14 Feb 2011 18:20:12 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications Thank you, very great article! I have only one question: How <span lang="en" class="short_text" id="result_box"><span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">I</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">notice</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">that the</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">loading</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">is</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">complete? I have some methods that should start when<span lang="en" id="result_box"><span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken"></span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">the</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">data</span> <span class="hps" title="Zur Anzeige alternativer Übersetzungen klicken">are </span></span></span></span>loades. http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment5456 Christian Schmidtchen http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Tue, 08 Feb 2011 17:25:15 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications Thanks 4 article! http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment5393 Aleksey http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Thu, 27 Jan 2011 05:48:11 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>Nice work but it seams that your PagedDataSource does not notify the interface when an entity is added or removed from the inner EntitySet....</p> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment5068 Marc Ederwind http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Tue, 14 Dec 2010 16:04:09 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications cachig is not implemented. you can do it by yourself in the method that retrieve the data. http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment4855 Andrea Boschin http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Sun, 14 Nov 2010 11:08:02 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>This is a great article, but i have some issues about performance , how can i get data from webservice just one time.</p> <p>In your example in every change  in page index , we need to request the data from webservice.</p> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment4854 Eyad Al-Hodiani http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Sun, 14 Nov 2010 11:04:33 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>Excellent article, Andrea.</p> <p>The behavior HC mentioned happened to me as well, HC's solution fixed it.</p> <p>Best regards,</p> <p>Long Xue</p> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment4821 Long Xue http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Fri, 05 Nov 2010 18:44:19 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>Yes, i'm referring to the attached project. </p> <p>When i run the project if i click last page in the DataPager and after that i click the next page the datapager goes to the next page.</p> <p></p> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment4743 HC http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Mon, 25 Oct 2010 15:39:16 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>Are you referring to the attached project? I didn't observed the described behavior in my example. Are you sure your ria service is returning the correct TotalEntitiesCount?</p> <p>bye.</p> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment4741 Andrea Boschin http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Mon, 25 Oct 2010 14:50:02 GMT RE: Paging WCF Ria Services entities in Model-View-ViewModel applications <p>Hello,</p> <p>You have some bugs in the class PagedDataSource. That bugs made possible to go after the last page in the DataPager.</p> <p> Changes need to fix that behavior.</p> <p></p> <pre style="font-family: consolas;"><span style="color: blue;">public</span> <span style="color: blue;">bool</span> MoveToLastPage()<br />        {<br />            <span style="color: blue;">this</span>.PageIndex = <span style="color: #2b91af;">Math</span>.Max(1, (<span style="color: blue;">int</span>)<span style="color: #2b91af;">Math</span>.Ceiling((<span style="color: blue;">double</span>)(((<span style="color: blue;">double</span>)<span style="color: blue;">this</span>.ItemCount) / ((<span style="color: blue;">double</span>)<span style="color: blue;">this</span>.PageSize)))) - 1;<br />            <span style="color: blue;">this</span>.Refresh();<br />            <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />        }</pre> <pre style="font-family: consolas;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span> MoveToNextPage()<br />        {<br />            <span style="color: blue;">int</span> maxPage = <span style="color: #2b91af;">Math</span>.Max(1, (<span style="color: blue;">int</span>)<span style="color: #2b91af;">Math</span>.Ceiling((<span style="color: blue;">double</span>)(((<span style="color: blue;">double</span>)<span style="color: blue;">this</span>.ItemCount) / ((<span style="color: blue;">double</span>)<span style="color: blue;">this</span>.PageSize))));<br />            <span style="color: blue;">if</span> (pageIndex < (maxPage -1))<br />            {<br />                <span style="color: blue;">this</span>.PageIndex++;<br />                <span style="color: blue;">this</span>.Refresh();<br />                <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />            }<br /> <br />            <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />        }</pre> <pre style="font-family: consolas;"><span style="color: blue;">public</span> <span style="color: blue;">bool</span> MoveToPage(<span style="color: blue;">int</span> pageIndex)<br />        {<br />            <span style="color: blue;">int</span> maxPage = <span style="color: #2b91af;">Math</span>.Max(1, (<span style="color: blue;">int</span>)<span style="color: #2b91af;">Math</span>.Ceiling((<span style="color: blue;">double</span>)(((<span style="color: blue;">double</span>)<span style="color: blue;">this</span>.ItemCount) / ((<span style="color: blue;">double</span>)<span style="color: blue;">this</span>.PageSize))));<br />            <span style="color: blue;">if</span> (pageIndex >= 0 && pageIndex < maxPage)<br />            {<br />                <span style="color: blue;">this</span>.PageIndex = pageIndex;<br />                <span style="color: blue;">this</span>.Refresh();<br />                <span style="color: blue;">return</span> <span style="color: blue;">true</span>;<br />            }<br /> <br />            <span style="color: blue;">return</span> <span style="color: blue;">false</span>;<br />        }<br /><br />In the code of the view you have the dataPager, if you register the PageIndexChangedEvent to the following method you disable the next button when in the last page.</pre> <pre style="font-family: consolas;"> <span style="color: blue;">void</span> pager_PageIndexChanged(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<br />        {<br />            <span style="color: blue;">var</span> pager = (<span style="color: #2b91af;">DataPager</span>)sender;<br /> <br />            <span style="color: blue;">int</span> pageCount = <span style="color: #2b91af;">Math</span>.Max(1, (<span style="color: blue;">int</span>)<span style="color: #2b91af;">Math</span>.Ceiling((<span style="color: blue;">double</span>)(((<span style="color: blue;">double</span>)pager.ItemCount) / ((<span style="color: blue;">double</span>)pager.PageSize))));<br />            <span style="color: blue;">if</span> (pager.PageIndex == pageCount - 1)<br />            {<br />                pager.IsTotalItemCountFixed = <span style="color: blue;">true</span>;<br />            }<br />            <span style="color: blue;">else</span> pager.IsTotalItemCountFixed = <span style="color: blue;">false</span>;<br /> <br />        }</pre> <br /> <br /> <p></p> http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx#comment4740 HC http://www.silverlightshow.net/items/Paging-WCF-Ria-Services-entities-in-Model-View-ViewModel-applications.aspx Mon, 25 Oct 2010 14:29:10 GMT