<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>MVVM on dwmkerr.com</title><link>https://dwmkerr.com/categories/mvvm/</link><description>Recent content in MVVM on dwmkerr.com</description><generator>Hugo -- gohugo.io</generator><language>en-uk</language><managingEditor>Dave Kerr</managingEditor><copyright>Copright &amp;copy; Dave Kerr</copyright><lastBuildDate>Mon, 25 Feb 2013 16:16:20 +0000</lastBuildDate><atom:link href="https://dwmkerr.com/categories/mvvm/index.xml" rel="self" type="application/rss+xml"/><item><title>Spider Solitaire and Augmented Reality</title><link>https://dwmkerr.com/spider-solitaire-and-augmented-reality/</link><pubDate>Mon, 25 Feb 2013 16:16:20 +0000</pubDate><guid>https://dwmkerr.com/spider-solitaire-and-augmented-reality/</guid><description>&lt;p&gt;A while ago, I made an implementation of Solitaire and Spider Solitaire using WPF and my Apex MVVM library. I wrote about it on the CodeProject, in an article called &lt;a title="Solitaire and Spider Solitaire for WPF" href="http://www.codeproject.com/Articles/252152/Solitaire-and-Spider-Solitaire-for-WPF"&gt;Solitaire and Spider Solitaire for WPF&lt;/a&gt; (imaginative title indeed).&lt;/p&gt;
&lt;p&gt;Anyway, just recently I got a very interesting message from rupam rupam, who has made an augmented reality version of the project! In his application, you use your webcam to play the game physically by picking up cards with gestures. Other gestures, like thumbs up and thumbs down are bound to commands in the game - here&amp;rsquo;s a screenshot:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=wCOjuPdBooI"&gt;&lt;img src="images/SpiderAugmented.jpg" alt="SpiderAugmented" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The project is called GesCard and as far as I know there isn&amp;rsquo;t a page showing the code - but there are more links on the YouTube video for the page. Check out the YouTube video with the link here &lt;a href="https://www.youtube.com/watch?v=wCOjuPdBooI"&gt;&lt;a href="https://www.youtube.com/watch?v=wCOjuPdBooI"&gt;https://www.youtube.com/watch?v=wCOjuPdBooI&lt;/a&gt;&lt;/a&gt;. Thanks to rupam for getting in touch and sharing this very cool code!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</description><category>CodeProject</category></item><item><title>Apex Part 2 - Adding Commands to an MVVM Application</title><link>https://dwmkerr.com/apex-part-2-adding-commands-to-an-mvvm-application/</link><pubDate>Tue, 15 May 2012 07:43:00 +0000</pubDate><guid>https://dwmkerr.com/apex-part-2-adding-commands-to-an-mvvm-application/</guid><description>&lt;p&gt;In Part 2 of my video tutorial series on using Apex I show you how you can add commands to an MVVM application. Commands let you rapidly add functionality to a ViewModel, whilst still maintaining separation from UI.&lt;/p&gt;
&lt;p&gt;&lt;iframe src="http://www.youtube.com/embed/wt7nncMNRG8" frameborder="0" width="420" height="315"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;A CodeProject article to accompany this video will be published shortly.&lt;/p&gt;</description><category>CodeProject</category></item><item><title>Apex Part 1 - Getting Started with the Apex SDK</title><link>https://dwmkerr.com/apex-part-1-getting-started-with-the-apex-sdk/</link><pubDate>Mon, 23 Apr 2012 05:35:00 +0000</pubDate><guid>https://dwmkerr.com/apex-part-1-getting-started-with-the-apex-sdk/</guid><description>&lt;p&gt;Create an MVVM application in minutes with the new Apex SDK!&lt;/p&gt;
&lt;p&gt;The video below shows this in action, see what you think.&lt;/p&gt;
&lt;p&gt;&lt;iframe src="http://www.youtube.com/embed/m4cx9w5fiwk" frameborder="0" width="420" height="315"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;There is also an accompanying article that describes what's going on. As always, would love to hear feedback!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.codeproject.com/Articles/371217/Apex-Part-1-Create-Your-First-MVVM-Application"&gt;http://www.codeproject.com/Articles/371217/Apex-Part-1-Create-Your-First-MVVM-Application&lt;/a&gt;&lt;/p&gt;</description><category>CodeProject</category></item><item><title>Funky WPF - Enumerations and the Combo Box</title><link>https://dwmkerr.com/funky-wpf-enumerations-and-the-combo-box/</link><pubDate>Wed, 18 Jan 2012 03:11:00 +0000</pubDate><guid>https://dwmkerr.com/funky-wpf-enumerations-and-the-combo-box/</guid><description>&lt;p class="MsoNormal"&gt;Binding a combo box to an enumeration in WPF is more work than it should be, creating an object data provider etc etc:&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;Window.Resources&amp;gt;
&amp;lt;ObjectDataProvider MethodName="GetValues"
ObjectType="{x:Type sys:Enum}"
x:Key="CharacterEnumValues"&amp;gt;
&amp;lt;ObjectDataProvider.MethodParameters&amp;gt;
&amp;lt;x:Type TypeName="Character" /&amp;gt;
&amp;lt;/ObjectDataProvider.MethodParameters&amp;gt;
&amp;lt;/ObjectDataProvider&amp;gt;
&amp;lt;/Window.Resources&amp;gt;&lt;/pre&gt;
&lt;p class="MsoNormal"&gt;Followed by&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;ComboBox SelectedItem="{Binding Character}"&lt;br /&gt; ItemsSource="{Binding &lt;br /&gt;Source={StaticResource CharacterValues}} "/&amp;gt;&lt;/pre&gt;
&lt;p class="brush: xml;"&gt;What a pain! I have just added 'EnumerationComboBox' to my Apex library - so now you can do this:&lt;/p&gt;
&lt;pre class="brush: xml;"&gt;&amp;lt;!-- The combo box, bound to an enumeration. --&amp;gt;
&amp;lt;apexControls:EnumerationComboBox &lt;br /&gt;SelectedEnumeration="{Binding Character}" /&amp;gt;&lt;/pre&gt;
&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;No need for an ObjectDataProvider, an items source or anything &amp;ndash; and if you decorate enum&amp;rsquo;s with the &amp;lsquo;[Description]&amp;rsquo; attribute, it&amp;rsquo;ll use the description in the combo.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;There&amp;rsquo;s an article/download here for anyone who's interested:&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://www.codeproject.com/KB/WPF/enumcombobox.aspx"&gt;http://www.codeproject.com/KB/WPF/enumcombobox.aspx&lt;/a&gt;&lt;/p&gt;</description><category>CodeProject</category></item><item><title>MVVM Commanding</title><link>https://dwmkerr.com/mvvm-commanding/</link><pubDate>Sat, 29 Oct 2011 08:31:00 +0000</pubDate><guid>https://dwmkerr.com/mvvm-commanding/</guid><description>&lt;p&gt;I have written an article that describes commanding in WPF, Silverlight and WP7 in detail. It is on the CodeProject at:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.codeproject.com/KB/WPF/consistentmvvmcommands.aspx"&gt;http://www.codeproject.com/KB/WPF/consistentmvvmcommands.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It uses the latest version of Apex (version 1.2) which will be released formally shortly. Enjoy!&lt;/p&gt;</description><category>CodeProject</category></item><item><title>MVVM: Asynchronous Commands</title><link>https://dwmkerr.com/mvvm-asynchronous-commands/</link><pubDate>Mon, 24 Oct 2011 03:51:00 +0000</pubDate><guid>https://dwmkerr.com/mvvm-asynchronous-commands/</guid><description>&lt;p&gt;The latest cut of the Apex Code (&lt;a href="http://apex.codeplex.com/SourceControl/changeset/changes/6701"&gt;http://apex.codeplex.com/SourceControl/changeset/changes/6701&lt;/a&gt;) contains a very cool new feature - Asynchronous Command Objects.&lt;/p&gt;
&lt;p&gt;An Asynchronous Command is a ViewModelCommand - the standard object used in Apex for commanding. However, what is different about this function is that it runs Asynchronously.&lt;/p&gt;
&lt;p&gt;One of the problems with running a view model command asynchronously is that generally the view model properties cannot be accessed - as they're created on a different dispatcher. This problem is resolved by using the 'ReportProgress' function. Here's an example:&lt;/p&gt;
&lt;pre class="brush: c-sharp;"&gt;public class SomeViewModel : ViewModel
{
public SomeViewModel()
{
// Create the command.
asyncCommand = new AsynchronousCommand(DoAsyncCommand, true);
}
&lt;p&gt;private void DoAsyncCommand()
{
for(int i = 0; i &amp;lt; 100; i++)
{
// Perform some long operation.
string message = DoSomeLongOperation();&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; // Add the message to the View Model - safely!
asyncCommand.ReportProgress(
() =&amp;amp;gt;
{
messages.Add(message);
}
);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;private ObservableCollection&amp;lt;string&amp;gt; messages =
new ObservableCollection&amp;lt;string&amp;gt;();&lt;/p&gt;
&lt;p&gt;public ObservableCollection&amp;lt;string&amp;gt; Messages
{
get { return messages; }
}&lt;/p&gt;
&lt;p&gt;private AsynchronousCommand asyncCommand;&lt;/p&gt;
&lt;p&gt;public AsynchronousCommand AsyncCommand
{
get { return asyncCommand; }
}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p class="brush: c-sharp;"&gt;In this basic mock-up we have a command called 'AsyncCommand' (which we could bind a button to for example) which invokes DoAsyncCommand. However, it invokes it Asynchronously. We can also update the ViewModel properties by using ReportProgress - meaning AsyncCommands can seamlessly provide live feedback while they're working - and we're keeping well locked in with the MVVM commanding model!&lt;/p&gt;
&lt;p class="brush: c-sharp;"&gt;Expect a full article soon on the CodeProject, until then the source is at:&lt;/p&gt;
&lt;p class="brush: c-sharp;"&gt;&lt;a href="http://apex.codeplex.com/SourceControl/changeset/changes/6701"&gt;http://apex.codeplex.com/SourceControl/changeset/changes/6701&lt;/a&gt;&lt;/p&gt;</description><category>CodeProject</category></item></channel></rss>