<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Yet Another Coding Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/avip/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/avip/feed.xml</link>
    <description>A Redmond dev blog... from Sydney; by Avi Pilosof.</description>
    <lastBuildDate>Tue, 16 Apr 2019 04:43:52 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Development Tip – Dispatching calls to the UI thread</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/development-tip-dispatching-calls-to-the-ui-thread</link>
      <pubDate>Wed, 28 Sep 2011 15:47:00 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2011/09/28/development-tip-dispatching-calls-to-the-ui-thread/</guid>
      <description><![CDATA[In Silverlight and WPF, if you wanted to update the UI from a thread you had launched, it was...]]></description>
      <content:encoded><![CDATA[<p>In Silverlight and WPF, if you wanted to update the UI from a thread you had launched, it was important that the UI update be executed on the UI thread, lest you get an invalid-cross-thread-access error.</p>
<p>You could ensure this by initially getting a pointer to the dispatcher for the UI thread, and then asking it to run your code. Something like this:</p>
<div class="csharpcode">
<div class="csharpcode">
<pre class="alt">_OriginalDispatcher = Application.Current.RootVisual.Dispatcher; </pre>
<pre>_OriginalDispatcher.BeginInvoke(myAction); </pre>
</div>
</div>
<p>In Win8 development, you don&rsquo;t have to worry about this nearly as often, because the need to spin up new threads is greatly reduced by the availability of the <strong>await</strong> keyword. That having been said, if you do end up starting your own thread, here&rsquo;s how you get the dispatcher:</p>
<div class="csharpcode">
<pre class="alt">_OriginalDispatcher = Window.Current.CoreWindow.Dispatcher;</pre>
</div>
<p>&nbsp;</p>
<p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Development Tip – Tab Control</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/development-tip-tab-control</link>
      <pubDate>Sun, 18 Sep 2011 19:55:00 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2011/09/18/development-tip-tab-control/</guid>
      <description><![CDATA[I'm trying to replicate a tab control in the Windows 8 //BUILD release. I&rsquo;m not talking about...]]></description>
      <content:encoded><![CDATA[<p>I'm trying to replicate a tab control in the Windows 8 //BUILD release. I&rsquo;m not talking about your traditional tab control with grey tabs and a static appearance; rather something that we&rsquo;ve seen throughout the demos at //BUILD; a set of clean links at the top of the app that flip to different sections of the app. Something&hellip; Metro-ish:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/7801.image_2AB39F1F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-05-76-metablogapi/7801.image_5F00_2AB39F1F.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="Zune's tabs" border="0" alt="Zune's tabs" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/6330.image_thumb_08E7C68E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-05-76-metablogapi/6330.image_5F00_thumb_5F00_08E7C68E.png" width="244" height="93" /></a></p>
<p>For now, I&rsquo;m baking my own very simple analog. The setup is like this: The links are a set of items in a <em>ListView</em> control, and the tab content is a set of <em>FlipViewItem</em>s within a <em>FlipView</em> control. The list&rsquo;s <em>SelectedIndex</em> is [two-way] bound to the <em>FlipView</em>&rsquo;s <em>SelectedIndex</em>, so they work in sync.</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">ListView</span> <span class="attr">x:Name</span><span class="kwrd">="lstTabs"</span> <span class="attr">SelectionMode</span><span class="kwrd">="Single"</span>
  <span class="attr">SelectedIndex</span><span class="kwrd">="{Binding SelectedIndex, ElementName=TabFlipView, Mode=TwoWay}"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">ListView.ItemsPanel</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">ItemsPanelTemplate</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">StackPanel</span> <span class="attr">Orientation</span><span class="kwrd">="Horizontal"</span><span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">ItemsPanelTemplate</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">ListView.ItemsPanel</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>Settings<span class="kwrd">&lt;/</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>Favourites<span class="kwrd">&lt;/</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">ListView</span><span class="kwrd">&gt;</span>

<span class="kwrd">&lt;</span><span class="html">FlipView</span> <span class="attr">x:Name</span><span class="kwrd">="TabFlipView"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">FlipViewItem</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>Settings go here<span class="kwrd">&lt;/</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">FlipViewItem</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">FlipViewItem</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>Favourites go here<span class="kwrd">&lt;/</span><span class="html">TextBlock</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">FlipViewItem</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">FlipView</span><span class="kwrd">&gt;</span></pre>
<p>As you can see, it&rsquo;s not perfect. At the very least, you would want to create a different style for the listbox so that the selected item looks a little different. However, it&rsquo;s really easy to get going with, and will do for now. One nice thing is that the FlipView control gives you free animations, so it looks fluid.</p>
<p>Another twist on this is instead of using a <em>FlipView</em>, you can create a <em>Frame</em> control, and then on the <em>ListView</em>&rsquo;s selection change event you can load different pages into the frame depending on what&rsquo;s selected.</p>
<p>&nbsp;</p>
<p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Development Tip – Packaging and loading files</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/development-tip-packaging-and-loading-files</link>
      <pubDate>Sun, 18 Sep 2011 19:54:00 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2011/09/18/development-tip-packaging-and-loading-files/</guid>
      <description><![CDATA[In Windows 8 I want to have a file in my solution which is packaged as part of the application, then...]]></description>
      <content:encoded><![CDATA[<p>In Windows 8 I want to have a file in my solution which is packaged as part of the application, then read at runtime. It&rsquo;s not immediately obvious how to do this because the app is running in an environment we&rsquo;re not used to, and using <em>StorageFile.GetFileFromPathAsync</em> doesn&rsquo;t let you provide relative paths. So what do you do? Where is your app installed so that you can provide the full path?</p>
<p>Here&rsquo;s the solution:</p>
<div class="csharpcode">
<pre class="alt"><span class="rem">// Assume the file in question is in a project folder called "Data",</span></pre>
<pre><span class="rem">// named "MyData.txt"</span></pre>
<pre class="alt">var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;</pre>
<pre>var file = await folder.GetFileAsync( <span class="str">@"Data\MyData.txt"</span> );</pre>
<pre class="alt">var winRTstream = await file.OpenAsync( FileAccessMode.Read );</pre>
<pre>var oldStylestream = winRTstream.OpenRead();</pre>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Development Tip - ObservableCollection doesn't work</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/development-tip-observablecollection-doesnt-work</link>
      <pubDate>Sat, 17 Sep 2011 17:53:00 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2011/09/17/development-tip-observablecollection-doesnt-work/</guid>
      <description><![CDATA[NOTE: This post applied in an the early preview of Win8. It's no longer applicable because the bug...]]></description>
      <content:encoded><![CDATA[<p><strong>NOTE: This post applied in an the early preview of Win8. It's no longer applicable because the bug in question no longer exists; ObservableCollection works just great :)</strong></p>
<p><strong>Original article below.</strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Just getting started with Win8 development, and will note what I learn in a series of posts.</p>
<p>&nbsp;</p>
<p>I'm finding that ObservableCollection isn't being honored by XAML elements in the //BUILD version of the tools. More specifically, either it's not firing collection changed events, or it is but they're being ignored. Seems this is a known limitation of the current dev drop, and there's an ObservableVector&lt;object&gt; which does work. However, using that throughout your code hurts because of all the casting required; it will also be messy to change when the tools catch up.</p>
<p>Until then, I created this wrapper that derives from <span style="font-family: consolas; color: #2b91af; font-size: x-small;" color="#2b91af" size="2" face="Consolas"><span style="font-family: consolas; color: #2b91af; font-size: x-small;" color="#2b91af" size="2" face="Consolas"><span style="font-family: consolas; color: #2b91af; font-size: x-small;" color="#2b91af" size="2" face="Consolas">ObservableCollection</span></span></span><span style="font-family: consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: consolas; font-size: x-small;" size="2" face="Consolas">&lt;T&gt;</span></span>, but also implements <span style="font-family: consolas; color: #2b91af; font-size: x-small;" color="#2b91af" size="2" face="Consolas"><span style="font-family: consolas; color: #2b91af; font-size: x-small;" color="#2b91af" size="2" face="Consolas"><span style="font-family: consolas; color: #2b91af; font-size: x-small;" color="#2b91af" size="2" face="Consolas">IObservableVector</span></span></span><span style="font-family: consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: consolas; font-size: x-small;" size="2" face="Consolas">&lt;</span></span><span style="font-family: consolas; color: #0000ff; font-size: x-small;" color="#0000ff" size="2" face="Consolas"><span style="font-family: consolas; color: #0000ff; font-size: x-small;" color="#0000ff" size="2" face="Consolas"><span style="font-family: consolas; color: #0000ff; font-size: x-small;" color="#0000ff" size="2" face="Consolas">object</span></span></span><span style="font-family: consolas; font-size: x-small;" size="2" face="Consolas"><span style="font-family: consolas; font-size: x-small;" size="2" face="Consolas">&gt;</span></span>. When the tools are fixed, you should be able to do a simple search/replace with ObservableCollection.</p>
<p>Please note that this isn't tested, it's not serious work, it's 5 minutes of Band-Aid which "seems to work on my machine". Use at own risk, etc.</p>
<div class="csharpcode">
<pre class="alt"><span class="kwrd">using</span> System;</pre>
<pre><span class="kwrd">using</span> System.Collections.Generic;</pre>
<pre class="alt"><span class="kwrd">using</span> System.Collections.ObjectModel;</pre>
<pre><span class="kwrd">using</span> Windows.Foundation.Collections;</pre>
<pre class="alt">&nbsp;</pre>
<pre><span class="kwrd">namespace</span> W8Shared</pre>
<pre class="alt">{</pre>
<pre>    <span class="kwrd">public</span> <span class="kwrd">class</span> BindableObservableCollection&lt;T&gt; : ObservableCollection&lt;T&gt;, IObservableVector&lt;<span class="kwrd">object</span>&gt;</pre>
<pre class="alt">    {</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">event</span> VectorChangedEventHandler&lt;<span class="kwrd">object</span>&gt; VectorChanged;</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">int</span> IndexOf(<span class="kwrd">object</span> item)</pre>
<pre class="alt">        {</pre>
<pre>            <span class="kwrd">return</span> <span class="kwrd">base</span>.IndexOf((T)item);</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">void</span> Insert(<span class="kwrd">int</span> index, <span class="kwrd">object</span> item)</pre>
<pre>        {</pre>
<pre class="alt">            <span class="kwrd">base</span>.Insert(index, (T)item);</pre>
<pre>            RaiseChange(CollectionChange.ItemInserted, (<span class="kwrd">uint</span>)index);</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">        <span class="kwrd">private</span> <span class="kwrd">void</span> RaiseChange(CollectionChange type, <span class="kwrd">uint</span> index)</pre>
<pre>        {</pre>
<pre class="alt">            <span class="kwrd">if</span> (VectorChanged != <span class="kwrd">null</span>)</pre>
<pre>                VectorChanged(<span class="kwrd">this</span>, <span class="kwrd">new</span> VectorChangedEventArgs(type, index));</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">new</span> <span class="kwrd">object</span> <span class="kwrd">this</span>[<span class="kwrd">int</span> index]</pre>
<pre>        {</pre>
<pre class="alt">            get</pre>
<pre>            {</pre>
<pre class="alt">                <span class="kwrd">return</span> (<span class="kwrd">object</span>)<span class="kwrd">base</span>[index];</pre>
<pre>            }</pre>
<pre class="alt">            set</pre>
<pre>            {</pre>
<pre class="alt">                <span class="kwrd">base</span>[index] = (T)<span class="kwrd">value</span>;</pre>
<pre>                RaiseChange(CollectionChange.ItemChanged, (<span class="kwrd">uint</span>)index);</pre>
<pre class="alt">            }</pre>
<pre>        }</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">void</span> Add(<span class="kwrd">object</span> item)</pre>
<pre class="alt">        {</pre>
<pre>            <span class="kwrd">base</span>.Add((T)item);</pre>
<pre class="alt">            RaiseChange(CollectionChange.ItemInserted, (<span class="kwrd">uint</span>)(<span class="kwrd">base</span>.Count-1));</pre>
<pre>        }</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">bool</span> Contains(<span class="kwrd">object</span> item)</pre>
<pre class="alt">        {</pre>
<pre>            <span class="kwrd">return</span> <span class="kwrd">base</span>.Contains((T)item);</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">void</span> CopyTo(<span class="kwrd">object</span>[] array, <span class="kwrd">int</span> arrayIndex)</pre>
<pre>        {</pre>
<pre class="alt">            <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException();</pre>
<pre>        }</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">bool</span> IsReadOnly</pre>
<pre class="alt">        {</pre>
<pre>            get { <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException(); }</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">bool</span> Remove(<span class="kwrd">object</span> item)</pre>
<pre>        {</pre>
<pre class="alt">            <span class="kwrd">int</span> index = <span class="kwrd">base</span>.IndexOf((T)item);</pre>
<pre>            <span class="kwrd">if</span> (index &gt;= 0)</pre>
<pre class="alt">            {</pre>
<pre>                var res = <span class="kwrd">base</span>.Remove((T)item);</pre>
<pre class="alt">                RaiseChange(CollectionChange.ItemRemoved, (<span class="kwrd">uint</span>)index);</pre>
<pre>                <span class="kwrd">return</span> res;</pre>
<pre class="alt">            }</pre>
<pre>&nbsp;</pre>
<pre class="alt">            <span class="kwrd">return</span> <span class="kwrd">false</span>;</pre>
<pre>        }</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">private</span> VectorEnumerator&lt;T&gt; _Enum;</pre>
<pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">new</span> IEnumerator&lt;<span class="kwrd">object</span>&gt; GetEnumerator()</pre>
<pre>        {</pre>
<pre class="alt">            <span class="kwrd">if</span> (_Enum == <span class="kwrd">null</span>)</pre>
<pre>            {</pre>
<pre class="alt">                _Enum = <span class="kwrd">new</span> VectorEnumerator&lt;T&gt;(<span class="kwrd">this</span>);</pre>
<pre>            }</pre>
<pre class="alt">&nbsp;</pre>
<pre>            <span class="kwrd">return</span> _Enum;            </pre>
<pre class="alt">        }</pre>
<pre>    }</pre>
<pre class="alt">&nbsp;</pre>
<pre>    <span class="kwrd">public</span> <span class="kwrd">class</span> VectorChangedEventArgs : IVectorChangedEventArgs</pre>
<pre class="alt">    {</pre>
<pre>        <span class="kwrd">public</span> VectorChangedEventArgs(CollectionChange type, <span class="kwrd">uint</span> index)</pre>
<pre class="alt">        {</pre>
<pre>            CollectionChange = type;</pre>
<pre class="alt">            Index = index;</pre>
<pre>        }</pre>
<pre class="alt">        <span class="kwrd">public</span> CollectionChange CollectionChange { get; set; }</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">uint</span> Index { get; set; }</pre>
<pre class="alt">    }</pre>
<pre>&nbsp;</pre>
<pre class="alt">    <span class="kwrd">public</span> <span class="kwrd">class</span> VectorEnumerator&lt;T&gt; : IEnumerator&lt;<span class="kwrd">object</span>&gt;</pre>
<pre>    {</pre>
<pre class="alt">        <span class="kwrd">private</span> IEnumerable&lt;T&gt; _Coll;</pre>
<pre>        <span class="kwrd">private</span> IEnumerator&lt;T&gt; _Enum;</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> VectorEnumerator(IEnumerable&lt;T&gt; internalColl)</pre>
<pre class="alt">        {</pre>
<pre>            _Coll = internalColl;</pre>
<pre class="alt">            _Enum = _Coll.GetEnumerator();</pre>
<pre>        }</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">object</span> Current</pre>
<pre class="alt">        {</pre>
<pre>            get { <span class="kwrd">return</span> (<span class="kwrd">object</span>)_Enum.Current; }</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">bool</span> MoveNext()</pre>
<pre class="alt">        {</pre>
<pre>            <span class="kwrd">return</span> _Enum.MoveNext();</pre>
<pre class="alt">        }</pre>
<pre>&nbsp;</pre>
<pre class="alt">        <span class="kwrd">public</span> <span class="kwrd">void</span> Reset()</pre>
<pre>        {</pre>
<pre class="alt">            _Enum.Reset();</pre>
<pre>        }</pre>
<pre class="alt">&nbsp;</pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">void</span> Dispose()</pre>
<pre class="alt">        {</pre>
<pre>            _Enum.Dispose();</pre>
<pre class="alt">        }</pre>
<pre>    }</pre>
<pre class="alt">}</pre>
</div>]]></content:encoded>
    </item>
    <item>
      <title>A simple pattern for AJAX with MVC</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/a-simple-pattern-for-ajax-with-mvc</link>
      <pubDate>Thu, 11 Aug 2011 20:06:55 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2011/08/11/a-simple-pattern-for-ajax-with-mvc/</guid>
      <description><![CDATA[This is mostly brainstorming; I’ve written some proof-of-concept (POC) code, and would love...]]></description>
      <content:encoded><![CDATA[<p>This is mostly brainstorming; I’ve written some proof-of-concept (POC) code, and would love feedback. I expect to hear that this has already been done earlier/better/prettier.</p>  <h2>The requirements:</h2>  <p>A very common pattern for our intranet sites is a page with search controls, a submit button, and an output section listing the results. I want to give this pattern a few features that suit my team:</p>  <ul>   <li>Have the page load very quickly.      <ul>       <li>Do this by splitting the initial page load from the data load into an AJAX call. </li>     </ul>   </li>    <li>Have the URL persistent and readable – I can copy/paste the current URL and it always represents what I see on the page; I can mail it to others and they can make sense of it.      <ul>       <li>Do this by adding the search parameters to the URL hash and interpreting the hash at page load time. </li>     </ul>   </li>    <li>Make such pages trivial to write; minimize the code.      <ul>       <li>Do this by writing a set of JS functions that can be used to make the above “just work”. </li>     </ul>   </li> </ul>  <h2>&#160;</h2>  <h2>The result:</h2>  <p><strong>MVC Controller methods:</strong></p>  <div class="csharpcode">   <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> ActionResult Index()</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>  <span class="rem">// Very simple view with just search controls; no logic/data.</span></pre>

  <pre><span class="lnum">   4:  </span>  <span class="kwrd">return</span> View();</pre>

  <pre class="alt"><span class="lnum">   5:  </span>}</pre>

  <pre><span class="lnum">   6:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   7:  </span><span class="kwrd">public</span> ActionResult IndexResults(<span class="kwrd">string</span> state = <span class="kwrd">null</span>, <span class="kwrd">string</span> revision = <span class="kwrd">null</span>,</pre>

  <pre><span class="lnum">   8:  </span>    <span class="kwrd">string</span> assignedTo = <span class="kwrd">null</span>, <span class="kwrd">string</span> keywords = <span class="kwrd">null</span>, <span class="kwrd">string</span> labs = <span class="kwrd">null</span>, </pre>

  <pre class="alt"><span class="lnum">   9:  </span>    <span class="kwrd">int</span>[] multiselect = <span class="kwrd">null</span>)</pre>

  <pre><span class="lnum">  10:  </span>{</pre>

  <pre class="alt"><span class="lnum">  11:  </span>  <span class="rem">// Load data, return partial view with results.</span></pre>

  <pre><span class="lnum">  12:  </span>}</pre>
</div>


<p>One thing to note is that the controls returned by the <em>Index</em> view bear the same names as the arguments for the <em>IndexResults</em> view. You’ll see why in a minute…</p>

<p><strong>Javascript code for the page:</strong></p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span>$(<span class="kwrd">function</span> () {</pre>

  <pre><span class="lnum">   2:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   3:  </span>    $(<span class="str">&quot;#btnSearch&quot;</span>).click(<span class="kwrd">function</span> () { runSearch() });</pre>

  <pre><span class="lnum">   4:  </span>    DD.queryHashToForm();</pre>

  <pre class="alt"><span class="lnum">   5:  </span>    runSearch();</pre>

  <pre><span class="lnum">   6:  </span>});</pre>

  <pre class="alt"><span class="lnum">   7:  </span>&#160;</pre>

  <pre><span class="lnum">   8:  </span><span class="kwrd">function</span> runSearch() {</pre>

  <pre class="alt"><span class="lnum">   9:  </span>&#160;</pre>

  <pre><span class="lnum">  10:  </span>    <span class="kwrd">var</span> urlObj = DD.formToQueryHash();</pre>

  <pre class="alt"><span class="lnum">  11:  </span>    DD.ajaxPost(</pre>

  <pre><span class="lnum">  12:  </span>        <span class="str">&quot;/Issues/IndexResults&quot;</span>,</pre>

  <pre class="alt"><span class="lnum">  13:  </span>        urlObj,</pre>

  <pre><span class="lnum">  14:  </span>        <span class="kwrd">function</span> (res) {</pre>

  <pre class="alt"><span class="lnum">  15:  </span>            $(<span class="str">&quot;#divResults&quot;</span>).html(res);</pre>

  <pre><span class="lnum">  16:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  17:  </span>    );</pre>

  <pre><span class="lnum">  18:  </span>}</pre>
</div>


<p>That’s it; together, these ingredients result in a page with a persistent URL that loads the data using AJAX, and even displays a progress indicator during the load. As you can see, this is code that’s very easy to write if you were making such a page.</p>

<p>So – here are the interesting lines from the JS above (note that “DD” is the library containing all the POC code):</p>

<ul>
  <li><strong>Line #3</strong>: This just causes a button press to re-run the search. </li>

  <li><strong>Line #4</strong>: This takes the current URL’s hash value and interprets it like a traditional querystring. It parses it, finds controls on the page which match the keys in the hash, then assigns values to those controls as per the hash. 

    <ul>
      <li>So as the page loads, the first thing it does it populate the form based on the URL, then runs the search. </li>
    </ul>
  </li>

  <li><strong>Line #10</strong>: This is the opposite of line #4 – it looks at the controls on the page, and creates an object from them with a property for each control’s value. It returns that object for use in the AJAX call, but then also serializes the object into the URL, in the same format expected by line #4. </li>

  <li><strong>Line #11</strong>: This custom method runs a normal AJAX post using jQuery, but wraps it up in before/after code that shows a default progress indicator. </li>

  <li><strong>Line #13</strong>: Note that we’re passing the object generated in line #10 into the AJAX call as the data. 

    <ul>
      <li>This relies on the fact that the MVC model binder will take a JSON object and split it into a controller method whose arguments correspond to that object’s properties; the MVC framework takes care of the heavy-lifting here. </li>
    </ul>
  </li>
</ul>

<p>Is this interesting? Should I post some of the code?</p>

<p>&#160;</p>

<p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Phone App 4: BabySoother</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/windows-phone-app-4-babysoother</link>
      <pubDate>Wed, 15 Dec 2010 13:32:04 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2010/12/15/windows-phone-app-4-babysoother/</guid>
      <description><![CDATA[They say necessity is the mother of invention... A new baby plus a few weeks of paternity leave were...]]></description>
      <content:encoded><![CDATA[<p>They say necessity is the mother of invention... A new baby plus a few weeks of paternity leave were the drivers in this case. The idea for this app started as a simple white-noise generator, and was basically a big “Play” button that played a recording of me saying “Shhhh”. Soon after I realized that my new boy reacted better to his mother’s voice than to most other things – so I wondered how to get that incorporated.</p>  <p>So this app now does the following:</p>  <ul>   <li>Plays one of several background sounds in a loop, for a predetermined time period </li>    <li>Occasionally overlays that with clips that you record yourself (e.g.; my wife’s voice) </li> </ul>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/6281.image_4DD00DCC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/6281.image_5F00_4DD00DCC.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/5040.image_thumb_50F1CFE7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/5040.image_5F00_thumb_5F00_50F1CFE7.png" width="148" height="244" /></a></p>  <p>During the advanced testing phase (i.e.; trying to get the baby to sleep), I would switch this on, and put it somewhere near him. Works like a charm (for different values of “charm”, depending on his level of anxiety ;))!!</p>  <p>Trial version is available; won’t play for very long. Check it out:</p>  <h2><a href="http://social.zune.net/redirect?type=phoneApp&amp;id=cbbfbaf3-0afc-df11-9264-00237de2db9e"><strong>BabySoother</strong></a></h2>  <p>&#160;</p>  <p>From a development point of view, I had some difficulties with this seemingly simple application:</p>  <ul>   <li>It’s quite “thready”, there are inter-thread interactions for things such as stopping the sounds after a given time (and/or when the user clicks “stop”), dealing with the microphone input, overlaying sounds, etc. Lots of callbacks being thrown around, lots of places to watch out for cross-thread access. </li>    <li>It was my first experience with XNA (in this case, for sound recording), and I had to play around with things before getting the microphone recording working well.      <ul>       <li>Some of that was due to a bug in the interaction between the Zune software and the Emulator (I think), meaning that sounds wouldn’t play, and I thought I had a bug – I didn’t, but it took ages to work out. </li>        <li>There is a very cool trick to showing the microphone input visually using data-binding. If anyone is interested, leave a commend and I’ll post some source. </li>     </ul>   </li>    <li>I really didn’t stick well to MVVM. Stuff such as telling the MediaElement to start/stop playing and switching on the microphone didn’t lend itself well to binding, and I was too sleep deprived to write behaviors. That would definitely be an improvement. </li>    <li>The marketplace submission failed twice; both times due to rules that require you play well with the rest of the phone (that’ll learn me to read the docs better):      <ul>       <li>You must be sure not to stop currently playing music without getting the user’s permission first. There’s a static property in MediaElement that allows you to check the current state. </li>        <li>You must get permission from the user before allowing your app to play music while the phone is locked. </li>     </ul>   </li> </ul>  <p>&#160;</p>  <p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>The simplest way to do design-time ViewModels with MVVM and Blend.</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/the-simplest-way-to-do-design-time-viewmodels-with-mvvm-and-blend</link>
      <pubDate>Sun, 05 Dec 2010 19:46:39 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2010/12/05/the-simplest-way-to-do-design-time-viewmodels-with-mvvm-and-blend/</guid>
      <description><![CDATA[&#160;  The problem is this: You’ve created your Views and ViewModels, but when you view them in...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>The problem is this: You’ve created your Views and ViewModels, but when you view them in Blend, you either see nothing, or the data you see is not useful for testing what you want in the view. There are various ways to deal with this, including writing code (either in the ViewModel or in a service locator) to return different data at design time.</p>  <p>I’m going to demonstrate a different way that doesn’t involve code, and is very simple and most importantly: Malleable.</p>  <p><strong>Assumptions/Prep:</strong></p>  <ul>   <li>I have a ViewModel class called “BooksViewModel” that supports the search UI and result-set. This has some non-trivial properties such as a collection of “Book” classes. </li>    <li>I have a View called “BooksView” that allows you to search for books, but I haven’t yet hooked up the data bindings (it’s easier to do after you create sample data). </li>    <li>I have no code to differentiate between design time and runtime. The code is geared purely towards runtime. </li> </ul>  <p><strong>What we’ll do:</strong></p>  <ol>   <li>Use Blend to create some purely fake sample data. </li>    <li>Assign the fake data as the data-context of the control you want, <em>in a design-time-only fashion</em>. </li>    <li>Create the bindings and play with the data. </li> </ol>  <p>&#160;</p>  <h3>The “Before” picture: A view showing very little:</h3>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/6607.image_7CBCEDB9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/6607.image_5F00_7CBCEDB9.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/3058.image_thumb_46F78292.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/3058.image_5F00_thumb_5F00_46F78292.png" width="211" height="244" /></a></p>  <p>&#160;</p>  <h3>Step 1: Create some fake data with Blend:</h3>  <p>Go to the “Data” tab, and create sample data <strong>from a class</strong>:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/6366.image_336A22F1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/6366.image_5F00_336A22F1.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/5125.image_thumb_4A48F46D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/5125.image_5F00_thumb_5F00_4A48F46D.png" width="244" height="111" /></a></p>  <p>Select your ViewModel as the class to base the sample data on. This is a giant time-saver:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/6685.image_215DDF64.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/6685.image_5F00_215DDF64.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/7268.image_thumb_0DD07FC3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/7268.image_5F00_thumb_5F00_0DD07FC3.png" width="244" height="170" /></a></p>  <p>A new folder + file will be created: SampleData\BooksSampleData.xaml. It’s pre-filled with fake data and ugly namespaces. For readability, I’ve done a find/replace on the namespaces. Here’s what I get:</p>  <pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">m:BooksViewModel</span>
  <span class="attr">xmlns:m</span><span class="kwrd">=&quot;clr-namespace:MVVM_DesignTime_Test.ViewModels&quot;</span>
  <span class="attr">IsSearching</span><span class="kwrd">=&quot;True&quot;</span>
  <span class="attr">SearchError</span><span class="kwrd">=&quot;Vestibulum cras&quot;</span>
  <span class="attr">SearchString</span><span class="kwrd">=&quot;Lectus fringilla eros&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">m:BooksViewModel.SearchResults</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">m:Book</span> <span class="attr">Author</span><span class="kwrd">=&quot;Aliquam aenean&quot;</span> <span class="attr">Name</span><span class="kwrd">=&quot;Curabitur maecenas class&quot;</span> <span class="attr">Price</span><span class="kwrd">=&quot;216.9&quot;</span><span class="kwrd">/&gt;</span>
        ......
        <span class="kwrd">&lt;</span><span class="html">m:Book</span> <span class="attr">Author</span><span class="kwrd">=&quot;Nec non&quot;</span> <span class="attr">Name</span><span class="kwrd">=&quot;Dictum etiam&quot;</span> <span class="attr">Price</span><span class="kwrd">=&quot;920.1&quot;</span><span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">m:Book</span> <span class="attr">Author</span><span class="kwrd">=&quot;Elit fermentum enim&quot;</span> <span class="attr">Name</span><span class="kwrd">=&quot;Erat fusce&quot;</span> <span class="attr">Price</span><span class="kwrd">=&quot;597.75&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">m:BooksViewModel.SearchResults</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">m:BooksViewModel</span><span class="kwrd">&gt;</span></pre>


<p>Two interesting things to notice about the above:</p>

<ul>
  <li>It automatically generated multiple entries for the collection (“SearchResults”), as well as generating properties for each item in that collection (“Book”). </li>

  <li>Pretty much any class can be instantiated like this in XAML, so no matter how deep/complex the ViewModel and dependent Model objects, you should be able to play with them in the text editor. </li>
</ul>

<p>&#160;</p>

<h3>Step 2: Assign the DataContext</h3>

<p>This is where the magic happens. Look back at the Data tab, and see that this new sample data source is now listed:</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/4113.image_1670D84F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/4113.image_5F00_1670D84F.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/1057.image_thumb_4A38CEA0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/1057.image_5F00_thumb_5F00_4A38CEA0.png" width="234" height="130" /></a></p>

<p>Simply <strong>drag-drop</strong> this guy onto the control which should use it as the data context. The mouse cursor will display text explaining what it will do. In my case, I dragged it onto the LayoutRoot grid, since I wanted everything under that to use it. Once this is done, you’ll notice a new XAML attribute on that control:</p>

<pre class="csharpcode">  d:DataContext=&quot;{d:DesignData /SampleData/BooksSampleData.xaml}&quot;</pre>


<p>This is the magic, especially the “d:” namespace declaration, which you’ll notice is mentioned in the page’s XAML declaration as such:</p>

<pre class="csharpcode">  mc:Ignorable=&quot;d&quot;</pre>
Basically, this tells everyone that they should ignore everything in the “d” namespace. But Blend chooses not to, and acts on it; this is why it works in design time without horking up the runtime. 

<p>&#160;</p>

<h3>Step 3: Create the data bindings</h3>

<p>Now when you select the “Data Binding…” context-menu for a control’s property, it will show you the properties that come from this data context, which correspond to your ViewModel, with the correct names, types, etc:</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/3124.image_286CF60F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/3124.image_5F00_286CF60F.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/5280.image_thumb_200920B8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/5280.image_5F00_thumb_5F00_200920B8.png" width="244" height="91" /></a></p>

<p>And BAM – there’s the data:</p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/2860.image_69B7F8A8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/2860.image_5F00_69B7F8A8.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/3034.image_thumb_756D3FDA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/3034.image_5F00_thumb_5F00_756D3FDA.png" width="244" height="202" /></a></p>

<p>&#160;</p>

<h3>Now what?</h3>

<ul>
  <li>Clean up the crappy namespaces in the XAML to make things more readable. </li>

  <li>Change the data to whatever you like using the XAML editor. </li>

  <li>When you make changes and save, the UI will auto-adjust; this is so much quicker than editing code. </li>

  <li>When you make changes to the ViewModel class, remember to change corresponding properties to your sample data. </li>

  <li>You can have multiple sample data files for multiple ViewModels, and use them on the same page – just drag each one onto the control which should use it. 
    <ul>
      <li>This is especially useful in pivot and panorama apps, where one page actually houses a whole app with multiple ViewModels. </li>
    </ul>
  </li>
</ul>

<p>&#160;</p>

<p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Phone App 3: Fact-Of-The-Day</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/windows-phone-app-3-fact-of-the-day</link>
      <pubDate>Thu, 28 Oct 2010 12:21:00 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2010/10/28/windows-phone-app-3-fact-of-the-day/</guid>
      <description><![CDATA[No prizes for guessing what this application does, but I will reveal it just in case: When you start...]]></description>
      <content:encoded><![CDATA[<p>No prizes for guessing what this application does, but I will reveal it just in case: When you start the application, it loads a bunch of trivia/facts from its own database as well as various RSS feeds, then shows them to you randomly.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/1780.Screen2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/1780.Screen2.png"><img height="244" width="148" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/7462.Screen2_thumb.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/7462.Screen2_5F00_thumb.png" alt="Screen2" border="0" title="Screen2" style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/2146.Screen1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/2146.Screen1.png"><img height="244" width="148" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/8400.Screen1_thumb.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/8400.Screen1_5F00_thumb.png" alt="Screen1" border="0" title="Screen1" style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" /></a></p>
<p>Here&rsquo;s the marketplace link:</p>
<p><a href="http://social.zune.net/redirect?type=phoneApp&amp;id=8a5fd405-f9de-df11-a844-00237de2db9e">http://social.zune.net/redirect?type=phoneApp&amp;id=8a5fd405-f9de-df11-a844-00237de2db9e</a></p>
<p>You just swipe the screen to reveal the next fact, and click the &ldquo;refresh&rdquo; button to load a whole new set.</p>
<p>This was a fairly simple application to write, but I did learn to optimize file storage &amp; loading, and a bunch about how [not] to create icons for the app and marketplace.</p>
<p>Even though it&rsquo;s simple, I find this application pretty fun to use. Great way to kill some time, very passive :)</p>
<p>This one doesn&rsquo;t have a trial mode, so I warn you: Don&rsquo;t spend the $0.99 unless you like facts!</p>
<p>&nbsp;</p>
<p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Phone App 2: MobileMobile, a fun game for toddlers.</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/windows-phone-app-2-mobilemobile-a-fun-game-for-toddlers</link>
      <pubDate>Thu, 28 Oct 2010 12:12:52 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2010/10/28/windows-phone-app-2-mobilemobile-a-fun-game-for-toddlers/</guid>
      <description><![CDATA[The second application I wrote for WP7 is a simple and fun game for tiny kids. The name - which I...]]></description>
      <content:encoded><![CDATA[<p>The second application I wrote for WP7 is a simple and fun game for tiny kids. The name - which I expect will confuse people – is a combination of “mobile” as in “This is running on a mobile phone”, and “mobile” as in “babies like to bash the animals hanging from this mobile”.</p>  <p>Here’s the marketplace link (you need Zune installed):</p>  <p><a href="http://social.zune.net/redirect?type=phoneApp&amp;id=8fe158e5-9ed8-df11-a844-00237de2db9e">http://social.zune.net/redirect?type=phoneApp&amp;id=8fe158e5-9ed8-df11-a844-00237de2db9e</a></p>  <p>Here’s what it looks like:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/2117.Screen1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/2117.Screen1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Screen1" border="0" alt="Screen1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/1524.Screen1_thumb.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/1524.Screen1_5F00_thumb.png" width="244" height="148" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/2045.Screen3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/2045.Screen3.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Screen3" border="0" alt="Screen3" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/2134.Screen3_thumb.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/2134.Screen3_5F00_thumb.png" width="244" height="148" /></a></p>  <p>The operation is simple:</p>  <ul>   <li>Choose one of a few scenes (farm, sea, snow).</li>    <li>Swipe across the page to reveal the rest of the landscape; it’s a large strip of various animals.</li>    <li>Touch an animal (or other item) to generate an animation and a sound.</li> </ul>  <p>I don’t have kids (not for the next 2-3 days, at least), but friends have told me that their 1-4 year olds enjoy this.</p>  <p>The interesting thing about this application is that there’s almost zero code; it’s virtually all XAML. The only code I have is a behavior that generates random animations based on a few parameters; it’s attached to each animal.</p>  <p>If you have small kids, give this a shot – there’s a free trial on the marketplace.</p>  <p>&#160;</p>  <p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Phone App 1: Feedr, an RSS reader.</title>
      <link>https://docs.microsoft.com/archive/blogs/avip/windows-phone-app-1-feedr-an-rss-reader</link>
      <pubDate>Thu, 28 Oct 2010 12:04:01 GMT</pubDate>
      <dc:creator><![CDATA[AviP]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/avip/2010/10/28/windows-phone-app-1-feedr-an-rss-reader/</guid>
      <description><![CDATA[My favorite way to learn a platform/language/technique is to just dive in and experiment, so for...]]></description>
      <content:encoded><![CDATA[<p>My favorite way to learn a platform/language/technique is to just dive in and experiment, so for Windows Phone 7 (WP7) I started writing some apps.</p>  <p>The first one I wrote is “Feedr”, which is an RSS reader:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/6521.Feeds.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/6521.Feeds.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Feeds" border="0" alt="Feeds" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/1323.Feeds_thumb.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/1323.Feeds_5F00_thumb.png" width="148" height="244" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/0675.Articles.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/0675.Articles.png"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Articles" border="0" alt="Articles" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/05/76/metablogapi/0172.Articles_thumb.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-05-76-metablogapi/0172.Articles_5F00_thumb.png" width="148" height="244" /></a></p>  <p>Here’s the marketplace link (you need Zune installed):</p>  <p><a href="http://social.zune.net/redirect?type=phoneApp&amp;id=7ee2f072-dbd5-df11-a844-00237de2db9e">http://social.zune.net/redirect?type=phoneApp&amp;id=7ee2f072-dbd5-df11-a844-00237de2db9e</a></p>  <p>It’s pretty no-frills at the moment, but it does what it says on the box, and is geared towards simplicity and ease of use. What I intend to add:</p>  <ul>   <li>Categorization of feeds </li>    <li>Importing an OPML (from where – web?) </li>    <li>A companion desktop/web Silverlight app, along with centralized syncing of state. </li> </ul>  <p>Feedback is welcomed; I haven’t actually tried this on a real phone (I don’t have one yet). There’s a trial mode available for it.</p>  <p>&#160;</p>  <p><script type="text/javascript">addthis_pub  = 'avip';</script>
<a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/button0-share.gif" width="83" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script>
</p>]]></content:encoded>
    </item>
  </channel>
</rss>