SilverlightShow: Working with collections in WCF RIA Services (part 2) 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: Working with collections in WCF RIA Services (part 2) <p>I got it working by referencing</p> <p><a href="http://blogs.msdn.com/b/kylemc/archive/2010/12/02/introducing-an-mvvm-friendly-domaindatasource-the-domaincollectionview.aspx">http://blogs.msdn.com/b/kylemc/archive/2010/12/02/introducing-an-mvvm-friendly-domaindatasource-the-domaincollectionview.aspx</a></p> <p>Thank you! :)</p> http://www.silverlightshow.net/items/Working-with-collections-in-WCF-RIA-Services-part-two.aspx#comment8491 lou8566 http://www.silverlightshow.net/items/Working-with-collections-in-WCF-RIA-Services-part-two.aspx Thu, 20 Sep 2012 10:20:18 GMT Re: Working with collections in WCF RIA Services (part 2) <p>Hi Kevin.</p> <p>I am having trouble following these steps, I have attempted to modify my code, so that I can have paging in my datagrid, however it doesn't work.</p> <p>Is it possible to put a link to your source code so I can figure out what I have done wrong?</p> <p>Here is my ViewModel</p> <div class="reCodeBlock" style="border: 1px solid #7f9db9; overflow-y: auto;"> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Net;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Controls;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Documents;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Ink;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Input;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Media;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Media.Animation;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Shapes;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.ComponentModel;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using Silverlight.NRMFA.DataLibrary;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Collections;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Data;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using Silverlight.NRMFA.Application.Commanding;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using Microsoft.Windows.Data.DomainServices;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.ServiceModel.DomainServices.Client;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">namespace Silverlight.NRMFA.Application.ViewModels</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">{</code></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;">public class DivisionViewModel : ViewModelBase</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _view;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> View</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _view;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_view != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_view = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("View");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private NRMFADomainContext _Context;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public NRMFADomainContext Context</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _Context;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_Context != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_Context = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Context");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _Divisions;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private Division _CurrentDivision;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public Division CurrentDivision</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _CurrentDivision;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_CurrentDivision != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_CurrentDivision = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("CurrentDivision");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> Divisions</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return this.View;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_Divisions != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_Divisions = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Divisions");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _source;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> Source</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _source;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_source != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_source = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Source");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private DomainCollectionViewLoader<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _loader;</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DomainCollectionViewLoader<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> Loader</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _loader;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_loader != value)</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_loader = value;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Loader");</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private LoadOperation<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> OnLoadDivisions()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">return this.Context.Load(this.Context.GetDivisionsQuery().SortAndPageBy(this.View));</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void OnLoadDivisionsCompleted(LoadOperation<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> op)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">if (op.HasError)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">op.MarkErrorAsHandled();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">else if (!op.IsCanceled)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">this.Source = new EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Context.Divisions);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">this.Source.Source = op.Entities;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (op.TotalEntityCount != -1)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">this.Divisions.SetTotalItemCount(op.TotalEntityCount);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DivisionViewModel()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">if (!IsDesignTime)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">InstantiateCommands();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">// Load Divisions</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">Context.Load<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Context.GetDivisionsQuery());</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">WireCommands();</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">using (this.View.DeferRefresh())</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">this.View.PageSize = 5;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">this.View.MoveToFirstPage();</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void InstantiateCommands()</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">Context = new NRMFADomainContext();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">this._loader = new DomainCollectionViewLoader<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(this.OnLoadDivisions, this.OnLoadDivisionsCompleted);</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">this._source = new EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Context.Divisions);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">this.View = new DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Loader, Source);</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private ICollectionView CreateView(IEnumerable source)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">CollectionViewSource cvs = new CollectionViewSource();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">cvs.Source = source;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">return cvs.View;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public RelayCommand SaveCommand</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">private set;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public RelayCommand CancelCommand</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">private set;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void WireCommands()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">SaveCommand = new RelayCommand(Save);</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">CancelCommand = new RelayCommand(Cancel);</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">SaveCommand.IsEnabled = true;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">CancelCommand.IsEnabled = true;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void Save()</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>             </code><span style="margin-left: 52px !important;"><code style="color: #000000;">if (Context.HasChanges)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (!Context.IsSubmitting)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">Context.SubmitChanges(so =></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;">if (so.HasError)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;">MessageBox.Show(String.Format("{0}{1}{2}",</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;">"There was an error saving one or more changes.",</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;">Environment.NewLine,</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;">"Please check the errors. " + so.Error.Message + " / " + so.Error.StackTrace));</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;">so.MarkErrorAsHandled();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">}, null);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void Cancel()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">if (Context.HasChanges)</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (!Context.IsSubmitting)</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">Context.RejectChanges();</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">}</code></span></div> </div> <br /> <p>and my xaml is as follows:</p> <div class="reCodeBlock" style="border: 1px solid #7f9db9; overflow-y: auto;"> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">navigation:Page</code> <code style="color: #808080;">xmlns:sdk</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk</a>"</code>  <code style="color: #808080;">x:Class</code><code style="color: #000000;">=</code><code style="color: blue;">"Silverlight.NRMFA.Application.Views.DivisionView"</code></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:x</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:d</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/expression/blend/2008">http://schemas.microsoft.com/expression/blend/2008</a>"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:mc</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.openxmlformats.org/markup-compatibility/2006">http://schemas.openxmlformats.org/markup-compatibility/2006</a>"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">mc:Ignorable</code><code style="color: #000000;">=</code><code style="color: blue;">"d"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:navigation</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:vm</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:Silverlight.NRMFA.Application.ViewModels"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:df</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:i</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:cmd</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL5"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">d:DesignWidth</code><code style="color: #000000;">=</code><code style="color: blue;">"640"</code> <code style="color: #808080;">d:DesignHeight</code><code style="color: #000000;">=</code><code style="color: blue;">"480"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">Title</code><code style="color: #000000;">=</code><code style="color: blue;">"DivisionView Page"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">UserControl.Resources</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">vm:DivisionViewModel</code> <code style="color: #808080;">x:Key</code><code style="color: #000000;">=</code><code style="color: blue;">"ViewModel"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">UserControl.Resources</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">Grid</code> <code style="color: #808080;">x:Name</code><code style="color: #000000;">=</code><code style="color: blue;">"LayoutRoot"</code> <code style="color: #808080;">DataContext</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Source={StaticResource ViewModel}}"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Horizontal"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"25"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid</code> <code style="color: #808080;">ItemsSource</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=Divisions}"</code> <code style="color: #808080;">Width</code><code style="color: #000000;">=</code><code style="color: blue;">"300"</code> <code style="color: #808080;">Height</code><code style="color: #000000;">=</code><code style="color: blue;">"300"</code> <code style="color: #808080;">VerticalAlignment</code><code style="color: #000000;">=</code><code style="color: blue;">"Top"</code> <code style="color: #808080;">SelectedItem</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=CurrentDivision, Mode=TwoWay}"</code> <code style="color: #808080;">AutoGenerateColumns</code><code style="color: #000000;">=</code><code style="color: blue;">"False"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid.Columns</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGridTextColumn</code> <code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"ID"</code> <code style="color: #808080;">Binding</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=DivisionID}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGridTextColumn</code> <code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"Division"</code> <code style="color: #808080;">Binding</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=DivisionName}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGridTextColumn</code> <code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"Year"</code> <code style="color: #808080;">Binding</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=YearID}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid.Columns</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Vertical"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataForm</code> <code style="color: #808080;">AutoGenerateFields</code><code style="color: #000000;">=</code><code style="color: blue;">"False"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Width</code><code style="color: #000000;">=</code><code style="color: blue;">"400"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Height</code><code style="color: #000000;">=</code><code style="color: blue;">"300"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"10,0,0,0"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">VerticalAlignment</code><code style="color: #000000;">=</code><code style="color: blue;">"Top"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"Player"</code> <code style="color: #808080;">AutoCommit</code><code style="color: #000000;">=</code><code style="color: blue;">"True"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">AutoEdit</code><code style="color: #000000;">=</code><code style="color: blue;">"False"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">CommandButtonsVisibility</code><code style="color: #000000;">=</code><code style="color: blue;">"All"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">ItemsSource</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=Divisions}"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">CurrentItem</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=CurrentDivision, Mode=TwoWay}"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataForm.EditTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">DataTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Vertical"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataField</code> <code style="color: #808080;">Label</code><code style="color: #000000;">=</code><code style="color: blue;">"Division"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                    </code><span style="margin-left: 144px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">TextBox</code> <code style="color: #808080;">Text</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding DivisionName, Mode=TwoWay}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataField</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataField</code> <code style="color: #808080;">Label</code><code style="color: #000000;">=</code><code style="color: blue;">"Year"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                    </code><span style="margin-left: 144px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">TextBox</code> <code style="color: #808080;">Text</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding YearID, Mode=TwoWay}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataField</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">DataTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataForm.EditTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataForm</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Horizontal"</code> <code style="color: #808080;">HorizontalAlignment</code><code style="color: #000000;">=</code><code style="color: blue;">"Right"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"0,0,30,0"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">Button</code> <code style="color: #808080;">Content</code><code style="color: #000000;">=</code><code style="color: blue;">"Save"</code> <code style="color: #808080;">Command</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding SaveCommand}"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"5"</code><code style="color: #000000;">/></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">Button</code> <code style="color: #808080;">Content</code><code style="color: #000000;">=</code><code style="color: blue;">"Cancel"</code> <code style="color: #808080;">Command</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding CancelCommand}"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"5"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">Grid</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">navigation:Page</code><code style="color: #000000;">></code></span></div> </div> <p>Thank you in advance.</p> <p>Lou</p> <p><br /> </p> <p><br /> </p> <p><br /> </p> <p><br /> </p> http://www.silverlightshow.net/items/Working-with-collections-in-WCF-RIA-Services-part-two.aspx#comment8490 lou8566 http://www.silverlightshow.net/items/Working-with-collections-in-WCF-RIA-Services-part-two.aspx Thu, 20 Sep 2012 09:24:10 GMT Re: Working with collections in WCF RIA Services (part 2) <p>Hi Kevin.</p> <p>I am having trouble following these steps, I have attempted to modify my code, so that I can have paging in my datagrid, however it doesn't work.</p> <p>Is it possible to put a link to your source code so I can figure out what I have done wrong?</p> <p>Here is my ViewModel</p> <div class="reCodeBlock" style="border: 1px solid #7f9db9; overflow-y: auto;"> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Net;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Controls;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Documents;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Ink;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Input;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Media;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Media.Animation;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Shapes;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.ComponentModel;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using Silverlight.NRMFA.DataLibrary;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Collections;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.Windows.Data;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using Silverlight.NRMFA.Application.Commanding;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using Microsoft.Windows.Data.DomainServices;</code></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">using System.ServiceModel.DomainServices.Client;</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;">namespace Silverlight.NRMFA.Application.ViewModels</code></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">{</code></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;">public class DivisionViewModel : ViewModelBase</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _view;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> View</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _view;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_view != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_view = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("View");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private NRMFADomainContext _Context;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public NRMFADomainContext Context</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _Context;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_Context != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_Context = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Context");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _Divisions;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private Division _CurrentDivision;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public Division CurrentDivision</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _CurrentDivision;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_CurrentDivision != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_CurrentDivision = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("CurrentDivision");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> Divisions</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return this.View;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_Divisions != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_Divisions = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Divisions");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _source;</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> Source</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _source;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_source != value)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_source = value;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Source");</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private DomainCollectionViewLoader<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> _loader;</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DomainCollectionViewLoader<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> Loader</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">return _loader;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">set</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (_loader != value)</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">_loader = value;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">OnPropertyChanged("Loader");</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private LoadOperation<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> OnLoadDivisions()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">return this.Context.Load(this.Context.GetDivisionsQuery().SortAndPageBy(this.View));</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void OnLoadDivisionsCompleted(LoadOperation<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">> op)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">if (op.HasError)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">op.MarkErrorAsHandled();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">else if (!op.IsCanceled)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">this.Source = new EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Context.Divisions);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">this.Source.Source = op.Entities;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (op.TotalEntityCount != -1)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">this.Divisions.SetTotalItemCount(op.TotalEntityCount);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public DivisionViewModel()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">if (!IsDesignTime)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">InstantiateCommands();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">// Load Divisions</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">Context.Load<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Context.GetDivisionsQuery());</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">WireCommands();</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">using (this.View.DeferRefresh())</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">this.View.PageSize = 5;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">this.View.MoveToFirstPage();</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void InstantiateCommands()</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">Context = new NRMFADomainContext();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">this._loader = new DomainCollectionViewLoader<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(this.OnLoadDivisions, this.OnLoadDivisionsCompleted);</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">this._source = new EntityList<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Context.Divisions);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">this.View = new DomainCollectionView<</code><code style="color: #006699; font-weight: bold;">Division</code><code style="color: #000000;">>(Loader, Source);</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private ICollectionView CreateView(IEnumerable source)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">CollectionViewSource cvs = new CollectionViewSource();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">cvs.Source = source;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">return cvs.View;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public RelayCommand SaveCommand</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">private set;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">public RelayCommand CancelCommand</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">get;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">private set;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void WireCommands()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">SaveCommand = new RelayCommand(Save);</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">CancelCommand = new RelayCommand(Cancel);</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">SaveCommand.IsEnabled = true;</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">CancelCommand.IsEnabled = true;</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"> </span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void Save()</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>             </code><span style="margin-left: 52px !important;"><code style="color: #000000;">if (Context.HasChanges)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (!Context.IsSubmitting)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">Context.SubmitChanges(so =></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;">if (so.HasError)</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;">MessageBox.Show(String.Format("{0}{1}{2}",</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;">"There was an error saving one or more changes.",</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;">Environment.NewLine,</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;">"Please check the errors. " + so.Error.Message + " / " + so.Error.StackTrace));</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;">so.MarkErrorAsHandled();</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">}, null);</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">private void Cancel()</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">if (Context.HasChanges)</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">if (!Context.IsSubmitting)</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">{</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;">Context.RejectChanges();</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;">}</code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;">}</code></span></div> </div> <br /> <p>and my xaml is as follows:</p> <div class="reCodeBlock" style="border: 1px solid #7f9db9; overflow-y: auto;"> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">navigation:Page</code> <code style="color: #808080;">xmlns:sdk</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk</a>"</code>  <code style="color: #808080;">x:Class</code><code style="color: #000000;">=</code><code style="color: blue;">"Silverlight.NRMFA.Application.Views.DivisionView"</code></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:x</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/winfx/2006/xaml">http://schemas.microsoft.com/winfx/2006/xaml</a>"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:d</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.microsoft.com/expression/blend/2008">http://schemas.microsoft.com/expression/blend/2008</a>"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:mc</code><code style="color: #000000;">=</code><code style="color: blue;">"<a href="http://schemas.openxmlformats.org/markup-compatibility/2006">http://schemas.openxmlformats.org/markup-compatibility/2006</a>"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">mc:Ignorable</code><code style="color: #000000;">=</code><code style="color: blue;">"d"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:navigation</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:vm</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:Silverlight.NRMFA.Application.ViewModels"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:df</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:i</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">xmlns:cmd</code><code style="color: #000000;">=</code><code style="color: blue;">"clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL5"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">d:DesignWidth</code><code style="color: #000000;">=</code><code style="color: blue;">"640"</code> <code style="color: #808080;">d:DesignHeight</code><code style="color: #000000;">=</code><code style="color: blue;">"480"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>           </code><span style="margin-left: 44px !important;"><code style="color: #808080;">Title</code><code style="color: #000000;">=</code><code style="color: blue;">"DivisionView Page"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">UserControl.Resources</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">vm:DivisionViewModel</code> <code style="color: #808080;">x:Key</code><code style="color: #000000;">=</code><code style="color: blue;">"ViewModel"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">UserControl.Resources</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">Grid</code> <code style="color: #808080;">x:Name</code><code style="color: #000000;">=</code><code style="color: blue;">"LayoutRoot"</code> <code style="color: #808080;">DataContext</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Source={StaticResource ViewModel}}"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Horizontal"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"25"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid</code> <code style="color: #808080;">ItemsSource</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=Divisions}"</code> <code style="color: #808080;">Width</code><code style="color: #000000;">=</code><code style="color: blue;">"300"</code> <code style="color: #808080;">Height</code><code style="color: #000000;">=</code><code style="color: blue;">"300"</code> <code style="color: #808080;">VerticalAlignment</code><code style="color: #000000;">=</code><code style="color: blue;">"Top"</code> <code style="color: #808080;">SelectedItem</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=CurrentDivision, Mode=TwoWay}"</code> <code style="color: #808080;">AutoGenerateColumns</code><code style="color: #000000;">=</code><code style="color: blue;">"False"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid.Columns</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGridTextColumn</code> <code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"ID"</code> <code style="color: #808080;">Binding</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=DivisionID}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGridTextColumn</code> <code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"Division"</code> <code style="color: #808080;">Binding</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=DivisionName}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">sdk:DataGridTextColumn</code> <code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"Year"</code> <code style="color: #808080;">Binding</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=YearID}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid.Columns</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">sdk:DataGrid</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Vertical"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataForm</code> <code style="color: #808080;">AutoGenerateFields</code><code style="color: #000000;">=</code><code style="color: blue;">"False"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Width</code><code style="color: #000000;">=</code><code style="color: blue;">"400"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Height</code><code style="color: #000000;">=</code><code style="color: blue;">"300"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"10,0,0,0"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">VerticalAlignment</code><code style="color: #000000;">=</code><code style="color: blue;">"Top"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">Header</code><code style="color: #000000;">=</code><code style="color: blue;">"Player"</code> <code style="color: #808080;">AutoCommit</code><code style="color: #000000;">=</code><code style="color: blue;">"True"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">AutoEdit</code><code style="color: #000000;">=</code><code style="color: blue;">"False"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">CommandButtonsVisibility</code><code style="color: #000000;">=</code><code style="color: blue;">"All"</code></span></span></div> <div style="background-color: #ffffff;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">ItemsSource</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=Divisions}"</code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                         </code><span style="margin-left: 100px !important;"><code style="color: #808080;">CurrentItem</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding Path=CurrentDivision, Mode=TwoWay}"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataForm.EditTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">DataTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Vertical"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataField</code> <code style="color: #808080;">Label</code><code style="color: #000000;">=</code><code style="color: blue;">"Division"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                    </code><span style="margin-left: 144px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">TextBox</code> <code style="color: #808080;">Text</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding DivisionName, Mode=TwoWay}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataField</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">df:DataField</code> <code style="color: #808080;">Label</code><code style="color: #000000;">=</code><code style="color: blue;">"Year"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                                    </code><span style="margin-left: 144px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">TextBox</code> <code style="color: #808080;">Text</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding YearID, Mode=TwoWay}"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                                </code><span style="margin-left: 128px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataField</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                            </code><span style="margin-left: 112px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                        </code><span style="margin-left: 96px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">DataTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataForm.EditTemplate</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">df:DataForm</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">StackPanel</code> <code style="color: #808080;">Orientation</code><code style="color: #000000;">=</code><code style="color: blue;">"Horizontal"</code> <code style="color: #808080;">HorizontalAlignment</code><code style="color: #000000;">=</code><code style="color: blue;">"Right"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"0,0,30,0"</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">Button</code> <code style="color: #808080;">Content</code><code style="color: #000000;">=</code><code style="color: blue;">"Save"</code> <code style="color: #808080;">Command</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding SaveCommand}"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"5"</code><code style="color: #000000;">/></code></span></span></div> <div style="background-color: #ffffff;"><span><code>                    </code><span style="margin-left: 80px !important;"><code style="color: #000000;"><</code><code style="color: #006699; font-weight: bold;">Button</code> <code style="color: #808080;">Content</code><code style="color: #000000;">=</code><code style="color: blue;">"Cancel"</code> <code style="color: #808080;">Command</code><code style="color: #000000;">=</code><code style="color: blue;">"{Binding CancelCommand}"</code> <code style="color: #808080;">Margin</code><code style="color: #000000;">=</code><code style="color: blue;">"5"</code> <code style="color: #000000;">/></code></span></span></div> <div style="background-color: #f8f8f8;"><span><code>                </code><span style="margin-left: 64px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>            </code><span style="margin-left: 48px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #ffffff;"><span style="margin-left: 0px !important;"> </span></div> <div style="background-color: #f8f8f8;"><span><code>        </code><span style="margin-left: 32px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">StackPanel</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #ffffff;"><span><code>    </code><span style="margin-left: 16px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">Grid</code><code style="color: #000000;">></code></span></span></div> <div style="background-color: #f8f8f8;"><span style="margin-left: 0px !important;"><code style="color: #000000;"></</code><code style="color: #006699; font-weight: bold;">navigation:Page</code><code style="color: #000000;">></code></span></div> </div> <p>Thank you in advance.</p> <p>Lou</p> <p><br /> </p> <p><br /> </p> <p><br /> </p> <p><br /> </p> http://www.silverlightshow.net/items/Working-with-collections-in-WCF-RIA-Services-part-two.aspx#comment8489 lou8566 http://www.silverlightshow.net/items/Working-with-collections-in-WCF-RIA-Services-part-two.aspx Thu, 20 Sep 2012 08:57:51 GMT