<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DM-V-VM part 7: Encapsulating commands</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx</link><description>In part 5 , I talked about commands and how they are used for behavior. Now, I want to talk about a better way to encapsulate them. First, I'll create a CommandModel class that encapsulates the RoutedCommand and the enabled/execute code. This is all pretty</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>WPF Patterns</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#774340</link><pubDate>Wed, 27 Sep 2006 23:31:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:774340</guid><dc:creator>Bryant Likes's Blog</dc:creator><description>If you're doing WPF development, you really need to check out Dan Crevier 's series on DataModel-View-ViewModel.</description></item><item><title>DataModel-View-ViewModel pattern series</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#818061</link><pubDate>Thu, 12 Oct 2006 05:00:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:818061</guid><dc:creator>Dan Crevier's Blog</dc:creator><description>&lt;p&gt;I thought I should add a post with the full list of posts in the D-V-VM pattern. They are: DataModel-View-ViewModel&lt;/p&gt;</description></item><item><title>re: DM-V-VM part 7: Encapsulating commands</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#870536</link><pubDate>Wed, 25 Oct 2006 01:28:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:870536</guid><dc:creator>makutaku</dc:creator><description>&lt;p&gt;Unfortunately this technique doesn't allow me to set multiple bindings in XAML because I can't do something such as:&lt;/p&gt;
&lt;p&gt;&amp;lt;Grid &lt;/p&gt;
&lt;p&gt; &amp;nbsp;local:CreateCommandBinding.Command=&amp;quot;{Binding MyCommand1}&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;local:CreateCommandBinding.Command=&amp;quot;{Binding MyCommand2}&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;gt;&lt;/p&gt;
&lt;p&gt;Any idea how could set multiple bindings for the command models in XAML?&lt;/p&gt;</description></item><item><title>re: DM-V-VM part 7: Encapsulating commands</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#870998</link><pubDate>Wed, 25 Oct 2006 06:07:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:870998</guid><dc:creator>dancre</dc:creator><description>&lt;p&gt;You'll need to modify CreateCommandBinding.OnCommandInvalidated to not clear the binding. To really do it right, you'll need to remove the old command binding when the command changes.&lt;/p&gt;
</description></item><item><title>re: DM-V-VM part 7: Encapsulating commands</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#881450</link><pubDate>Fri, 27 Oct 2006 19:47:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:881450</guid><dc:creator>makutaku</dc:creator><description>&lt;p&gt;If I remove the old command binding when the command changes then, using my example above, MyCommand2 binding will remove MyCommand1 binding. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I want to have multiple simultaneous bindings then I guess I just have to not clear the binding. I'll try that.&lt;/p&gt;</description></item><item><title>re: DM-V-VM part 7: Encapsulating commands</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#881730</link><pubDate>Fri, 27 Oct 2006 20:17:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:881730</guid><dc:creator>makutaku</dc:creator><description>&lt;p&gt;Unfortunately I can't have two simultaneous bindings using XAML:&lt;/p&gt;
&lt;p&gt;&amp;lt;Grid&lt;/p&gt;
&lt;p&gt; local:CreateCommandBinding.Command=&amp;quot;{Binding MyCommand1}&amp;quot;&lt;/p&gt;
&lt;p&gt; local:CreateCommandBinding.Command=&amp;quot;{Binding MyCommand2}&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;gt;&lt;/p&gt;
&lt;p&gt;because I got an error saying:&lt;/p&gt;
&lt;p&gt;Error	54	''p:CommandBindingCreator.Command' is a duplicate attribute name. Line 17, position 3.' XML is not valid.&lt;/p&gt;
&lt;p&gt;The only way I found to do that was to create another attached property called Commands which takes a collection of CommandModels.&lt;/p&gt;</description></item><item><title>re: DM-V-VM part 7: Encapsulating commands</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#905324</link><pubDate>Tue, 31 Oct 2006 06:02:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:905324</guid><dc:creator>dancre</dc:creator><description>&lt;p&gt;Sorry, I wasn't clear on the clearing. I meant you should remove e.OldValue from the binding in the property changed handler.&lt;/p&gt;
&lt;p&gt;To handle multiple bindings, you could also allow CreateCommandBinding take a IEnumerable&amp;lt;CommandModel&amp;gt; and expose a list from the model.&lt;/p&gt;
</description></item><item><title>COMMANDS</title><link>http://blogs.msdn.com/dancre/archive/2006/09/15/dm-v-vm-part-7-encapsulating-commands.aspx#8834835</link><pubDate>Tue, 05 Aug 2008 23:09:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8834835</guid><dc:creator>WPF Client Development</dc:creator><description>&lt;p&gt;If you are trying to write an application in WPF that separates the UI from the underlying business logic&lt;/p&gt;</description></item></channel></rss>