SilverlightShow: Data Driven Applications with MVVM Part I: The Basics 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: Data Driven Applications with MVVM Part I: The Basics I am using ADO.Net Entity Framework in the Model Folder. Do i have to create an interface for each entity in my ADO.Net Entity Model? http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment8068 harrykod http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Wed, 16 May 2012 22:26:19 GMT Re: Data Driven Applications with MVVM Part I: The Basics <p>Greate article boss.</p> <p>Thanks a lot.</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment8053 ShohelShipon http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Mon, 14 May 2012 05:36:44 GMT Re: Data Driven Applications with MVVM Part I: The Basics Where is the OperationEventArgs come from? http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment7991 haiyun592 http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Wed, 25 Apr 2012 15:57:30 GMT Re: Data Driven Applications with MVVM Part I: The Basics <p>Hi,</p> <p>I am new to Silverlight. Really good article.</p> <p>I have a question. </p> <p>I see "<span style="background-color: white; font-family: 'courier new', courier, monospace; font-size: 8pt; line-height: 12pt;">OperationEventArgs" being used. Is this part of MVVM tool kit or am i missing any assembly?</span></p> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span style="color: #0000ff;">namespace</span> MVVMProductsDemo.Model</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> BooksLoadedEventArgs : OperationEventArgs</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> {</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> IEnumerable<Book> Books { get; set; }</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> </pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> BooksLoadedEventArgs(IEnumerable<Book> books)</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> {</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.Books = books;</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> }</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> }</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span>}</pre> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment7554 Karthik http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Mon, 20 Feb 2012 02:18:07 GMT Re: Data Driven Applications with MVVM Part I: The Basics <p>Hi,</p> <p>I am new to Silverlight. Really good article.</p> <p>I have a question. </p> <p>I see "<span style="background-color: white; font-family: 'courier new', courier, monospace; font-size: 8pt; line-height: 12pt;">OperationEventArgs" being used. Is this part of MVVM tool kit or am i missing any assembly?</span></p> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span style="color: #0000ff;">namespace</span> MVVMProductsDemo.Model</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum2" style="color: #606060;"> </span>{</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum3" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> BooksLoadedEventArgs : OperationEventArgs</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum4" style="color: #606060;"> </span> {</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum5" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> IEnumerable<Book> Books { get; set; }</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum6" style="color: #606060;"> </span> </pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum7" style="color: #606060;"> </span> <span style="color: #0000ff;">public</span> BooksLoadedEventArgs(IEnumerable<Book> books)</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum8" style="color: #606060;"> </span> {</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum9" style="color: #606060;"> </span> <span style="color: #0000ff;">this</span>.Books = books;</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum10" style="color: #606060;"> </span> }</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: white; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum11" style="color: #606060;"> </span> }</pre> <pre style="font-size: 8pt; line-height: 12pt; background-color: #f4f4f4; padding-bottom: 0px; overflow-x: visible; overflow-y: visible; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; padding-left: 0px; width: 682px; padding-right: 0px; font-family: 'courier new', courier, monospace; direction: ltr; padding-top: 0px;border-style: none;"><span id="lnum12" style="color: #606060;"> </span>}</pre> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment7553 Karthik http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Sun, 19 Feb 2012 23:54:06 GMT Re: Data Driven Applications with MVVM Part I: The Basics This is not good for huge ERP type system.If some one follow MVVM sure he will depress and stop coding. http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment6528 ImranAli http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Fri, 16 Sep 2011 07:52:52 GMT Re: Data Driven Applications with MVVM Part I: The Basics <p>Thank you Zoltan, very good explanation. I have been with my fingers freezed for weeks without knowing where to start this big WPF project. At least know I have a path.</p> <p>Let's move on with the next chapter.</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment6462 MauricioLeyzaola http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Mon, 29 Aug 2011 04:27:01 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Can you upload the source code zip as well?</p> <p>Nice article</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment6162 Shailesh http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Wed, 18 May 2011 23:24:20 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Thank you very much for this article !!</p> <p>Things are getting very clear for me now .</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4340 Surf-O-Matic http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Thu, 26 Aug 2010 19:06:34 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>If you don't mind, can you please post a zip of the same?</p> <p>thanks</p> <p>Sunit</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4317 Sunit Joshi http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Mon, 23 Aug 2010 20:41:56 GMT RE: Data Driven Applications with MVVM Part I: The Basics The full solution is supposed to be there... and I just double checked it, and the solution is there. (I used winrar) http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4315 zoltan.arvai http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Mon, 23 Aug 2010 10:05:08 GMT RE: Data Driven Applications with MVVM Part I: The Basics Is the full project contained in the rar files? I can't see anything other than the Mvmm dlls and App files? http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4313 Sunit http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Mon, 23 Aug 2010 05:26:45 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Nabeel: </p> <p>In your code you write:  </p> <p>var mainwindow = new MainWindow(); (here you have a mainwindow variable)<br />   this.MainWindow.DataContext = view; (here you set this.MainWindows which is at this point is not the previously created instance... plus you set the datacontext to view... what is view? that should be a viewmodel...<br />   this.MainWindow.Show();</p> <p>This should be something like this:</p> <pre style="font-family: consolas;">            <span style="color: blue;">var</span> mainwindow = <span style="color: blue;">new</span> <span style="color: #2b91af;">MainWindow</span>();<br />            <span style="color: blue;">this</span>.MainWindow = mainwindow;<br />            <span style="color: blue;">this</span>.MainWindow.DataContext = <span style="color: #a31515;">viewModel</span>;<br />            <span style="color: blue;">this</span>.MainWindow.Show();</pre> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4103 zoltan.arvai http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Sat, 31 Jul 2010 12:17:53 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Great article, simple and to the point.</p> <p> Thanks!</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4100 Rafael http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Sat, 31 Jul 2010 06:30:29 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Hi Zoltan,</p> <p>I am new to Wpf and Silverlight. I am porting your solution to wpf and I can't seem to figure out the equivalent of line 7</p> <p></p> <pre style="border-style: none; text-align: left; padding: 0px; line-height: 12pt; overflow: visible; background-color: white; margin: 0em; width: 100%; font-family: 'courier new',courier,monospace; direction: ltr; color: black; font-size: 8pt;">this.RootVisual = view;</pre> <p></p> <p>in the ApplicationStartup event. I have tried something like this </p> <p></p> <p> var mainwindow = new MainWindow();<br />   this.MainWindow.DataContext = view;<br />   this.MainWindow.Show();</p> <p> But when the MainWindow get displayed its all empty? Any idea?</p> <p>Regards,<br /> Nabeel</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment4079 Nabeel http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Wed, 28 Jul 2010 19:26:30 GMT RE: Data Driven Applications with MVVM Part I: The Basics Thanks this is great stuff. http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment3809 Mattias http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Wed, 16 Jun 2010 16:39:13 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Hi!</p> <p>I totally agree with you. Your suggestion makes this more effective and most of the time that is what I do myself (mostly due to the lack of time :) ) However in this article I tried to follow the design guidelines present in the .NET Framework. To make it somewhat more readable.</p> <p>There are two more articles, already sent to the silverlightshow guys. Timing is up to them :) The article was intended to be only a single one, however as I wrote it, it was growing pretty fast :) Now I'm thinking on a 4th part :) There is still much to show :)</p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment3801 zoltan.arvai http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Tue, 15 Jun 2010 18:10:10 GMT RE: Data Driven Applications with MVVM Part I: The Basics <p>Quite simple and at the same time accurate explanation of the MVVM basics !!! I would suggest just one improvement in your code, it is in the model. I see that you've created a BooksLoadedEventArgs, if you need to load, let's say Customers, you have to create another EventArgs, e.g: CustomersLoadedEventArgs. In this case you can replace both of the custom EventArgs with one generic class. For example, something like this:<br /> <br /> public class EntityResultEventArgs<T> : OperationEventArgs<br /> {<br />     public EntityResultEventArgs( IEnumerable<T> result )<br />     {<br />         this.Result = result;<br />     }<br /> <br />     public IEnumerable<T> Result<br />     {<br />         get;<br />         protected set;<br />     }<br /> }</p> <p>Otherwise the rest of the code is absolutely the same as I would do it. I am looking forward for the rest of the articles.<br /> Best Regards<br /> </p> <p></p> http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx#comment3800 ppopadiyn http://www.silverlightshow.net/items/Data-Driven-Applications-with-MVVM-Part-I.-The-Basics.aspx Tue, 15 Jun 2010 16:25:52 GMT