<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for HiTech Magic Ltd</title>
	<atom:link href="http://blog.hitechmagic.com/Index.php?feed=comments-rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.hitechmagic.com</link>
	<description>A little magic goes a long way</description>
	<lastBuildDate>Tue, 04 Sep 2012 03:12:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by Raziaar</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-34</link>
		<dc:creator>Raziaar</dc:creator>
		<pubDate>Tue, 04 Sep 2012 03:12:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-34</guid>
		<description>Well this is how I ended up doing it... doubt it&#039;s the proper way, but it works.

viewModel.HostChat = new DelegateCommand(ExecuteHostChat, CanHostChat);
            viewModel.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ViewModelPropertyChanged);
        }

        void ViewModelPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == &quot;Name&quot; &#124;&#124; e.PropertyName == &quot;Port&quot; &#124;&#124; e.PropertyName == &quot;Address&quot;)
            {
                (viewModel.HostChat as DelegateCommand).RaiseCanExecuteChanged();
            }
        }

public bool CanHostChat()
        {
            if (String.IsNullOrEmpty(viewModel.Address) &#124;&#124;
                String.IsNullOrEmpty(viewModel.Port) &#124;&#124;
                String.IsNullOrEmpty(viewModel.Name))
            {
                return false;
            }
            else
                return true;

        }</description>
		<content:encoded><![CDATA[<p>Well this is how I ended up doing it&#8230; doubt it&#8217;s the proper way, but it works.</p>
<p>viewModel.HostChat = new DelegateCommand(ExecuteHostChat, CanHostChat);<br />
            viewModel.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ViewModelPropertyChanged);<br />
        }</p>
<p>        void ViewModelPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)<br />
        {<br />
            if (e.PropertyName == &#8220;Name&#8221; || e.PropertyName == &#8220;Port&#8221; || e.PropertyName == &#8220;Address&#8221;)<br />
            {<br />
                (viewModel.HostChat as DelegateCommand).RaiseCanExecuteChanged();<br />
            }<br />
        }</p>
<p>public bool CanHostChat()<br />
        {<br />
            if (String.IsNullOrEmpty(viewModel.Address) ||<br />
                String.IsNullOrEmpty(viewModel.Port) ||<br />
                String.IsNullOrEmpty(viewModel.Name))<br />
            {<br />
                return false;<br />
            }<br />
            else<br />
                return true;</p>
<p>        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by Raziaar</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-33</link>
		<dc:creator>Raziaar</dc:creator>
		<pubDate>Tue, 04 Sep 2012 02:33:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-33</guid>
		<description>So I&#039;m well on my way with this... at least I&#039;d like to think so. Part of me thinks I&#039;m doing everything wrong. But oh well.

A problem I&#039;m facing right now is dealing with the CanExecute of an ICommand to enable or disable buttons in my view. I can&#039;t figure out how to accomplish this in the Controller.</description>
		<content:encoded><![CDATA[<p>So I&#8217;m well on my way with this&#8230; at least I&#8217;d like to think so. Part of me thinks I&#8217;m doing everything wrong. But oh well.</p>
<p>A problem I&#8217;m facing right now is dealing with the CanExecute of an ICommand to enable or disable buttons in my view. I can&#8217;t figure out how to accomplish this in the Controller.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by Raziaar</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-30</link>
		<dc:creator>Raziaar</dc:creator>
		<pubDate>Sat, 18 Aug 2012 21:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-30</guid>
		<description>I know that a ViewModel should know nothing about the model it&#039;s exposing for the View. How should a ViewModel represent a Person object in the Model. Does the ViewModel define it&#039;s own class, and the Controller do a conversion between the Person on the Controller, and the Person on the ViewModel?

How does all that work? What&#039;s the ideal way you prefer?</description>
		<content:encoded><![CDATA[<p>I know that a ViewModel should know nothing about the model it&#8217;s exposing for the View. How should a ViewModel represent a Person object in the Model. Does the ViewModel define it&#8217;s own class, and the Controller do a conversion between the Person on the Controller, and the Person on the ViewModel?</p>
<p>How does all that work? What&#8217;s the ideal way you prefer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by admin</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-29</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 12 Aug 2012 19:39:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-29</guid>
		<description>It will take a few examples I think to clarify things, but your example is correct:

The VM ICommand properties are again only a named placeholder for a View to bind to. Any given controller could reuse the same VM in different ways, by assigning different ICommand code/delegates.</description>
		<content:encoded><![CDATA[<p>It will take a few examples I think to clarify things, but your example is correct:</p>
<p>The VM ICommand properties are again only a named placeholder for a View to bind to. Any given controller could reuse the same VM in different ways, by assigning different ICommand code/delegates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by Raziaar</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-28</link>
		<dc:creator>Raziaar</dc:creator>
		<pubDate>Sun, 12 Aug 2012 19:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-28</guid>
		<description>Thank you for the response. Unfortunately I do not seem to be following along completely, and for that I apologize.

If your ViewModel has ICommand properties set for various commands such as ProductAddedCommand, are you simply defining the methods in your Controller and assigning them after instantiating the ViewModel?

viewModel.ProductAddedCommand = new DelegateCommand(AddProduct, CanAddProduct);

Or are you taking a different approach?</description>
		<content:encoded><![CDATA[<p>Thank you for the response. Unfortunately I do not seem to be following along completely, and for that I apologize.</p>
<p>If your ViewModel has ICommand properties set for various commands such as ProductAddedCommand, are you simply defining the methods in your Controller and assigning them after instantiating the ViewModel?</p>
<p>viewModel.ProductAddedCommand = new DelegateCommand(AddProduct, CanAddProduct);</p>
<p>Or are you taking a different approach?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by admin</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-27</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 12 Aug 2012 09:50:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-27</guid>
		<description>Good questions. MVVM has everyone populating data from inside their ViewModel, making them smarter than they should be (the VMs, not the people). Controllers will populate ViewModels from the data sources instead (usually in response to app events/messages). 

Basically whatever code you would have in your viewmodel at the moment, to populate data members, migrates directly to a controller. If you have an EF model in your VM, then your controller will have an EF instance (or create one when needed) and move the query results to a VM property. If you use service calls to populate data, then those service calls will now happen in the controller. 

It is possible to bind DataSources to a VM as well, so you can also make a lot of drag-drop data stuff you author in XAML more flexible and not bound to a single source. All binding and datasource related operations use reflection to connect/move data so only the shape of the data (i.e. the property names) are actually important. That&#039;s why I say &quot;a VM provides a certain shape of data&quot;. 

The main thing to remember with MVCVM is that the individual building blocks should appear completely independant and only responsible for things they &lt;em&gt;should&lt;/em&gt; know about. This makes them easily unit testable. The only cross-dependant parts in an MVCVM app are the controllers. Controllers do need to know about their Views, their View Models and their Data Sources/Models. Controllers are the glue that connects your otherwise independant components into an overall app. They are the app logic. Everything else is just there to serve them :)

I will be updating this series with examples, specifically a large multi-module Prism app, over time. </description>
		<content:encoded><![CDATA[<p>Good questions. MVVM has everyone populating data from inside their ViewModel, making them smarter than they should be (the VMs, not the people). Controllers will populate ViewModels from the data sources instead (usually in response to app events/messages). </p>
<p>Basically whatever code you would have in your viewmodel at the moment, to populate data members, migrates directly to a controller. If you have an EF model in your VM, then your controller will have an EF instance (or create one when needed) and move the query results to a VM property. If you use service calls to populate data, then those service calls will now happen in the controller. </p>
<p>It is possible to bind DataSources to a VM as well, so you can also make a lot of drag-drop data stuff you author in XAML more flexible and not bound to a single source. All binding and datasource related operations use reflection to connect/move data so only the shape of the data (i.e. the property names) are actually important. That&#8217;s why I say &#8220;a VM provides a certain shape of data&#8221;. </p>
<p>The main thing to remember with MVCVM is that the individual building blocks should appear completely independant and only responsible for things they <em>should</em> know about. This makes them easily unit testable. The only cross-dependant parts in an MVCVM app are the controllers. Controllers do need to know about their Views, their View Models and their Data Sources/Models. Controllers are the glue that connects your otherwise independant components into an overall app. They are the app logic. Everything else is just there to serve them <img src='http://hitechmagic.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I will be updating this series with examples, specifically a large multi-module Prism app, over time. </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Silverlight MVCVM &#8211; MVVM With Controllers by Raziaar</title>
		<link>http://blog.hitechmagic.com/?page_id=513#comment-26</link>
		<dc:creator>Raziaar</dc:creator>
		<pubDate>Sun, 12 Aug 2012 08:13:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.hitechmagic.com/?page_id=513#comment-26</guid>
		<description>I&#039;m excited to read about what you have to say on this subject. I&#039;m still trying to learn what I can since so many of these concepts are new to me and I&#039;m trying to learn them all at once.

The main question I have right now... is how do the controllers go about populating all the properties of the ViewModels? I can&#039;t figure out if it&#039;s something that should be dependency injected, or if the controller simply goes through and sets all the properties(making sure to get every last one) to initialize it and later in methods as events are triggered.

I&#039;m kind of at a hang up right here as I try to figure out how the viewmodel gets everything it needs from the controller, since you say the viewmodel is just a dumb container of data for the view.

Examples will definitely be helpful.</description>
		<content:encoded><![CDATA[<p>I&#8217;m excited to read about what you have to say on this subject. I&#8217;m still trying to learn what I can since so many of these concepts are new to me and I&#8217;m trying to learn them all at once.</p>
<p>The main question I have right now&#8230; is how do the controllers go about populating all the properties of the ViewModels? I can&#8217;t figure out if it&#8217;s something that should be dependency injected, or if the controller simply goes through and sets all the properties(making sure to get every last one) to initialize it and later in methods as events are triggered.</p>
<p>I&#8217;m kind of at a hang up right here as I try to figure out how the viewmodel gets everything it needs from the controller, since you say the viewmodel is just a dumb container of data for the view.</p>
<p>Examples will definitely be helpful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
