<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>pedrolamas.com</title>
        <link>https://www.pedrolamas.com</link>
        <description>Programming and Tinkering</description>
        <lastBuildDate>Fri, 26 Sep 2025 19:49:13 GMT</lastBuildDate>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs>
        <generator>GatsbyJS</generator>
        <copyright>All rights reserved 2025, Pedro Lamas</copyright>
        <item>
            <title><![CDATA[Accessing Sonos devices across VLANs on a Ubiquiti UDM network]]></title>
            <link>https://www.pedrolamas.com/2023/03/28/accessing-sonos-devices-across-vlans-on-a-ubiquiti-udm-network/</link>
            <guid>https://www.pedrolamas.com/2023/03/28/accessing-sonos-devices-across-vlans-on-a-ubiquiti-udm-network/</guid>
            <pubDate>Tue, 28 Mar 2023 14:00:23 GMT</pubDate>
            <content:encoded><![CDATA[<p>My network has been (over)powered by a Ubiquiti UniFi Dream Machine (<abbr title="UniFi Dream Machine">UDM</abbr>) for a few years now.</p><p>Using the excellent UniFi web interface, I created a few VLANs so I could easily segregate my IoT devices from the rest of the network.</p><p>That was all working fine until last Christmas I got myself a Sonos Arc soundbar, and realized that I couldn’t have it on <abbr title="Virtual Local Area Network">VLAN</abbr> 20 and access on my Android phone in <abbr title="Virtual Local Area Network">VLAN</abbr> 40…</p><p>After a lot of googling on this problem, I came to realize that Sonos uses multicasting to “announce” their devices to the network; so as long as I could replay those multicast packages across the VLANs, I should be able to access it on my phone without issues!</p><p>I found the <a href="https://github.com/alsmith/multicast-relay">multicast-relay</a> from Al Smith on GitHub, which it said to it could be used to “relay broadcast and multicast packets between interfaces”… so just what I needed!</p><p>My solution was to <abbr title="Secure Shell">SSH</abbr> into the <abbr title="UniFi Dream Machine">UDM</abbr> (this is disabled by default, but you can enable it on the web interface) and execute the following commands to download and run the <code>multicast-relay.py</code> python script:</p><pre><code class="language-sh">cd /tmp
wget https://github.com/alsmith/multicast-relay/raw/master/multicast-relay.py
python3 multicast-relay.py --foreground --verbose --noMDNS --interfaces br20 br40
</code></pre><p>On the final part of the above commands you will notice “br20 br40”, those are my VLANs 20 and 40, so you will have to change those to match your own VLANs.</p><p>Once the script started, I could see it relaying the Sonos multicast data across VLANs just as I wanted, and when I opened up the Sonos Android app, it quickly found the device and allowed me to add it to the app!</p><p>Now the interesting bit is that after adding the Sonos device to the app, I could just stop the script (hit <kbd>Ctrl+C</kbd>) and then delete it, as the app will still work just fine even without seeing those multicast packets ever.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming and Tinkering!]]></title>
            <link>https://www.pedrolamas.com/2022/02/01/programming-and-tinkering/</link>
            <guid>https://www.pedrolamas.com/2022/02/01/programming-and-tinkering/</guid>
            <pubDate>Tue, 01 Feb 2022 17:21:16 GMT</pubDate>
            <content:encoded><![CDATA[<p>Though this might come as no surprise given the lack of content here lately, I’ve been mostly away from any type of Windows development work - not only on a personal level but also on a professional one.</p><p>The raw reality is that the work opportunities in Windows Development in the <abbr title="United Kingdom">UK</abbr> have mostly disappeared, and right now, there are no signs of this changing anytime soon!</p><p>For the past 2.5 years I’ve been working mostly with .NET Core 3.1, .NET 5, and .NET 6, building backend solutions, running inside Docker containers or as Lambda functions, hosted in Microsoft Azure and/or Amazon Web Services - and I have learned a lot with people who have more experience than I did on this type of work!</p><p>On a personal level, I’ve been experimenting a lot more in Home Automation, using <a href="https://www.home-assistant.io/">Home Assistant</a>, <a href="https://esphome.io/">ESPHome</a>, and <a href="https://www.zigbee2mqtt.io/">Zigbee2MQTT</a>.</p><p>A couple of months ago I bought an Ender-3 V2 3D printer which I have now heavily modified, and that took me to learn more about <abbr title="Computer Aided Design">CAD</abbr> modeling, 3D printing, electronics, and start contributing in some related open-source projects - but I’m going to leave that for another post!</p><p>As I continue this new phase, I wanted to drop the “Windows Development” moniker on this website and replace it with a more appropriate “Programming and Tinkering”!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring changes in webpages with Home Assistant]]></title>
            <link>https://www.pedrolamas.com/2021/07/08/monitoring-changes-in-webpages-with-home-assistant/</link>
            <guid>https://www.pedrolamas.com/2021/07/08/monitoring-changes-in-webpages-with-home-assistant/</guid>
            <pubDate>Thu, 08 Jul 2021 10:05:12 GMT</pubDate>
            <content:encoded><![CDATA[<p>I’m a huge fan of <a href="https://www.home-assistant.io/">Home Assistant</a> and use it to automate most of my devices at my home, and for that matter, I follow a few people on Twitter and YouTube that share valuable information on it!</p><p>One of those is <a href="https://www.youtube.com/c/BeardedTinker">BeardedTinker</a> channel on YouTube, as he provides particularly good step-by-step explanations in his videos - if you are interested on the topic, I do recommend following his YouTube channel!</p><p>A few weeks ago he published a video on <a href="https://www.youtube.com/watch?v=7KexZUKqEqA">Smart Home Service monitoring with Home Assistant</a>, where he showed how we can check that a website is working correctly by using curl on the webpage address and then checking for the 200 OK status return code.</p><p>I wanted to improve on that by checking a webpage for changes and then creating automations on that!</p><p>There are a few ways to achieve this, I will be discussing two of them!</p><h2>Using the ETag header</h2><p>First, here is a quick explanation on what the ETag header is (more <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag">here</a>):</p><blockquote><p>The ETag <abbr title="Hypertext Transfer Protocol">HTTP</abbr> response header is an identifier for a specific version of a resource. It lets caches be more efficient and save bandwidth, as a web server does not need to resend a full response if the content has not changed.</p></blockquote><p>As all we want is the webpage headers, we can use a HEAD request instead of the GET, so here is how the whole thing will work:</p><pre><code class="language-yaml">sensor:
  - platform: command_line
    name: webpage_monitor
    command: &gt;-
      python3 -c &quot;import requests; response = requests.head(&#x27;https://www.zigbee2mqtt.io/information/supported_devices.html&#x27;); print(response.headers.get(&#x27;ETag&#x27;))&quot;
    scan_interval: 10800
</code></pre><p>On the above example, we have a sensor called <code>webpage_monitor</code> that will execute a python command to perform a HEAD request on the <a href="https://www.zigbee2mqtt.io/information/supported_devices.html">Zigbee2MQTT Devices</a> webpage, and return the <code>ETag</code> header value.</p><p>Now all we need is an automation that will trigger when the state (value) of this sensor changes:</p><pre><code class="language-yaml">automation:
  - alias: Show notification when webpage_monitor changes
    trigger:
      - platform: state
        entity_id: sensor.webpage_monitor
    action:
      - service: persistent_notification.create
        data:
          message: &#x27;Page changed!&#x27;
</code></pre><h2>Using the page content</h2><p>Not all webpages have an <code>ETag</code> header, and for those cases (or when the <code>ETag</code> somehow changes without the content actually changing), we can instead create a hash of the page content and use that in our automation!</p><p>Here is an example with the <a href="https://www.home-assistant.io/">Home Assistant</a> homepage:</p><pre><code class="language-yaml">sensor:
  - platform: command_line
    name: webpage_monitor
    command: &gt;-
      python3 -c &quot;import hashlib, requests; response = requests.get(&#x27;https://www.home-assistant.io/&#x27;); print(hashlib.sha256(response.content).hexdigest())&quot;
    scan_interval: 10800
</code></pre><p>The above will calculate a unique hash of the content of the page and store that in the sensor.</p><p>As before, all we need then is to create an automation that will run when the sensor state changes!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to connect to a WireGuard VPN server from a Docker container]]></title>
            <link>https://www.pedrolamas.com/2020/11/20/how-to-connect-to-a-wireguard-vpn-server-from-a-docker-container/</link>
            <guid>https://www.pedrolamas.com/2020/11/20/how-to-connect-to-a-wireguard-vpn-server-from-a-docker-container/</guid>
            <pubDate>Fri, 20 Nov 2020 14:15:12 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/b5628659fd070dbe1bb30d2390671545/How-to-connect-to-a-WireGuard-VPN-server-from-a-Docker-container.png" alt="How to connect to a WireGuard VPN server from a Docker container" class="webfeedsFeaturedVisual" /></p><p>I like to use Docker containers for pretty much everything I do, so I wanted to see if I could have a Docker container connect to a WireGuard <abbr title="Virtual Private Network">VPN</abbr> Server, and then have other containers share that same connection.</p><p>Surprisingly, this is not only possible, but it is also amazingly easy to achieve!</p><h2>Preparation</h2><p>We will be using the <a href="https://hub.docker.com/r/linuxserver/wireguard">linuxserver/wireguard</a> Docker image. This image works in either WireGuard server or client mode, but we will be using it just as a client.</p><p>For this post, I will focus on having the <abbr title="Virtual Private Network">VPN</abbr> connection isolated from the host system by using a custom bridge network.</p><p>We will also be using <a href="https://docs.docker.com/compose/">docker-compose</a> to maintain the full Docker stack.</p><p>We will create a folder called “wireguard” that will store all the data from the container. Inside this folder we will place a file called “wg0.conf” that will hold the WireGuard connection settings.</p><p>Our final folder structure looks like this:</p><pre><code class="language-text">.\docker-compose.yaml
.\wireguard\wg0.conf
</code></pre><h2>Getting a WireGuard <abbr title="Virtual Private Network">VPN</abbr> server</h2><p>There are quite a few <abbr title="Virtual Private Network">VPN</abbr> Server providers out there that already provide WireGuard servers for you to connect, so if you already have a <abbr title="Virtual Private Network">VPN</abbr> service subscription, you should probably check there first for WireGuard support!</p><p>I’ve been a happy customer of <a href="https://torguard.net/aff.php?aff=6755">TorGuard</a> for a few years now, and I was quite pleased to see them adding WireGuard support recently.</p><p>If you are considering registering for a TorGuard subscription plan, you can use <a href="https://torguard.net/aff.php?aff=6755">this link</a> and the promo code <strong>PL50P</strong> to get a lifetime discount of 50% off!</p><blockquote><p><em>Disclaimer: neither TorGuard nor anyone else sponsored this post, but as I said I’ve been paying and using their products for quite a few years to the point I do recommend them. The link above is an affiliate link and does pay a small commission to me for anyone who does use it with the discount code.</em></p></blockquote><p>Here is how you can generate the WireGuard connection settings in TorGuard:</p><ol><li>Login and open the <a href="https://torguard.net/tgconf.php?action=vpn-openvpnconfig">Config Generator</a></li><li>Change the ”<abbr title="Virtual Private Network">VPN</abbr> Tunnel type” to “WireGuard”</li><li>Select one of the available servers on the ”<abbr title="Virtual Private Network">VPN</abbr> Server Hostname/IP”</li><li>Enter your ”<abbr title="Virtual Private Network">VPN</abbr> Username” and ”<abbr title="Virtual Private Network">VPN</abbr> Password”</li><li>Click on “Generate Config”</li></ol><p>The last step is to copy the “Config Output” contents to the “wg0.conf” file.</p><h2>Running WireGuard from Docker</h2><p>Here is the basic “docker-compose.yaml” file to get the container running:</p><pre><code class="language-yaml">version: &#x27;3.7&#x27;

services:
  wireguard:
    image: linuxserver/wireguard
    container_name: wireguard
    restart: unless-stopped
    networks:
      - backbone
    volumes:
      - &#x27;./wireguard:/config&#x27;
      - &#x27;/lib/modules:/lib/modules:ro&#x27;
    environment:
      - PUID=1000
      - PGID=1000
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1

networks:
  backbone:
    driver: bridge
</code></pre><p>If you read the <a href="https://hub.docker.com/r/linuxserver/wireguard">Docker image documentation</a>, you will see it requires some special capabilities that need to be enabled for it to work. You can see those on the <code>cap_add</code> and <code>sysctls</code> yaml nodes above.</p><p>We are now ready to start, so just enter <code>docker-compose up -d</code> to create the “backbone” bridge network, and create and start the “wireguard” container.</p><h2>Testing and Validating</h2><p>Run the following commands now:</p><pre><code class="language-bash">curl -w &quot;\n&quot; ifconfig.me

docker exec -it wireguard curl -w &quot;\n&quot; ifconfig.me
</code></pre><p>The first command will retrieve your real Public IP, matching the one your <abbr title="Internet Service Provider">ISP</abbr> has provided you with.</p><p>The second command will do the same but from inside the Wireguard Docker container, and it should match the connected WireGuard <abbr title="Virtual Private Network">VPN</abbr> Server IP.</p><h2>Sharing the connection with other containers</h2><p>Under the <code>services</code> node of our “docker-compose.yaml” file, add the following service:</p><pre><code class="language-yaml"># under the existing &quot;services:&quot; node, add the following content
ubuntu:
  depends_on:
    - wireguard
  image: ubuntu
  container-name: ubuntu
  network_mode: service:wireguard
  command: &gt;-
    sleep 10 &amp;&amp; curl -w &quot;\n&quot; ifconfig.me
</code></pre><p>After saving the changes to the file, run <code>docker-compose up -d</code> to start this new container.</p><p>The above service will start a new Ubuntu Docker container after the WireGuard one, pause for 10 seconds, and then retrieve the Public IP address; if all goes well, this should match the WireGuard <abbr title="Virtual Private Network">VPN</abbr> Server IP.</p><p>The trick here is to use the <code>network_mode: service:&lt;service-name&gt;</code> to make the new container reuse another container’s network stack!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exposing the client IPs to Docker containers in Synology NAS]]></title>
            <link>https://www.pedrolamas.com/2020/11/04/exposing-the-client-ips-to-docker-containers-on-synology-nas/</link>
            <guid>https://www.pedrolamas.com/2020/11/04/exposing-the-client-ips-to-docker-containers-on-synology-nas/</guid>
            <pubDate>Wed, 04 Nov 2020 11:28:11 GMT</pubDate>
            <content:encoded><![CDATA[<p>I have a DS412+ Synology NAS that’s been running continuously for a few years now!</p><p>It’s a great NAS, but it’s the extra features like being able to easily run Docker containers that makes me like it even more!</p><p>I recently tried running an <a href="https://adguard.com/en/adguard-home/overview.html">AdGuard Home</a> Docker container and with no surprise, it worked perfectly; after setting the NAS IP as the <abbr title="Domain Name System">DNS</abbr> server in my router, all my local <abbr title="Domain Name System">DNS</abbr> requests were sent to AdGuard Home and I could see it doing its job of blocking any known advertisement or tracking hosts.</p><p>There was however a small issue: the IP of the client machine was not showing up!</p><p><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:720px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:36.11111111111111%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAr0lEQVQY032PwW7EIAxE+f9vrHpIT6VZwgawwTNAle5KTS55escZy+MA+J/V+zVscYwxbxnjbRZKpQMooqWIiIrU3sc5dPJytyiK4ij/pUfvnSSAnAuvAJhzppT9usb4fP34CNGpaoxbKRn/GK6QDCGklFLO1VptjZ3rY3NmJiKttfu1Pn59xw///AyyBFk2Waqpa832fTez+zJJMxzLx3xJdgdAVUnel48xBrKf5C+C55sMfCq1TgAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="AdGuard Home Docker container not showing the client IPs" title="AdGuard Home Docker container not showing the client IPs" src="/static/a7105c7536877f52b2c4a254e05e7eff/37523/AdGuard-Home-no-client-IPs.png" srcSet="/static/a7105c7536877f52b2c4a254e05e7eff/e9ff0/AdGuard-Home-no-client-IPs.png 180w,/static/a7105c7536877f52b2c4a254e05e7eff/f21e7/AdGuard-Home-no-client-IPs.png 360w,/static/a7105c7536877f52b2c4a254e05e7eff/37523/AdGuard-Home-no-client-IPs.png 720w,/static/a7105c7536877f52b2c4a254e05e7eff/2bef9/AdGuard-Home-no-client-IPs.png 1024w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">AdGuard Home Docker container not showing the client IPs</figcaption>
  </figure></p><p>I found a <a href="https://github.com/pi-hole/docker-pi-hole/issues/135">similar issue</a> had previously been open on Pi-hole GitHub repository, but no solution provided.</p><p>As I couldn’t find any fix for this problem, I posted the issue to the <a href="https://community.synology.com/enu/forum/1/post/134465">Synology Community</a> forums, but that didn’t provide a solution either…</p><p>At this stage, I tried comparing the Docker iptables on my Synology NAS with the ones in a Raspberry Pi, and that’s when I noticed that the Docker pre-routing rules were missing.</p><p>I then <abbr title="Secure Shell">SSH</abbr>‘ed to the Synology NAS and manually added the missing rules:</p><pre><code class="language-bash">sudo iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
sudo iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER
</code></pre><p><strong>Success!!</strong></p><p>I could now see the client IPs and hostnames on AdGuard Home:</p><p><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:720px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:40.55555555555556%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAyUlEQVQY032R247DIAxE+f9PTZVA8AUbm7CCqBFtpT3iAY01HhuCmW3ba9teR4zXJ33huvoqIDuLB3cX1cIioiK6en4bzRYDZGOxoKqISMQAcJ4nACBizkBErbXHmfOo1Go+xd67uwfVioilFGYmojK5L+sUhcdsZmbu3to47kFEcs4pJQD42nMlxZgzcJHpHbi3YGb65incrGarI7PNTe65iUsoRfZ9jzEdb1JKU4nu/pjjEY+YRGtrl9+vABTWhP++6s5cqNX+AEX41WM35NYxAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="AdGuard Home Docker container now showing the client IPs or hostnames" title="AdGuard Home Docker container now showing the client IPs or hostnames" src="/static/1ee5f6f3045df49c0cccbe7f073e5481/37523/AdGuard-Home-client-IPs-and-hostnames.png" srcSet="/static/1ee5f6f3045df49c0cccbe7f073e5481/e9ff0/AdGuard-Home-client-IPs-and-hostnames.png 180w,/static/1ee5f6f3045df49c0cccbe7f073e5481/f21e7/AdGuard-Home-client-IPs-and-hostnames.png 360w,/static/1ee5f6f3045df49c0cccbe7f073e5481/37523/AdGuard-Home-client-IPs-and-hostnames.png 720w,/static/1ee5f6f3045df49c0cccbe7f073e5481/2bef9/AdGuard-Home-client-IPs-and-hostnames.png 1024w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">AdGuard Home Docker container now showing the client IPs or hostnames</figcaption>
  </figure></p><p>I was aware that this change to the Synology iptables was not a permanent one and would have to be done on every reboot, so the next step was to get a more permanent solution!</p><p>The simplest solution I found was to use the Synology Task Scheduler to run a user-defined script on every reboot</p><p>You can check the script and instructions on how to use it <a href="https://gist.github.com/pedrolamas/db809a2b9112166da4a2dbf8e3a72ae9">here</a>:</p><script src="https://gist.github.com/pedrolamas/db809a2b9112166da4a2dbf8e3a72ae9.js"></script><p>Please be aware that <strong>these changes to the iptables will probably mess with the Synology Firewall</strong>, so just be careful with that if you do use the Firewall!</p><p>Also be aware that this goes with <abbr title="Works On My Machine">WOMM</abbr> certification, so it works on my machine but there are no guarantees it will work on yours!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My first steps with Azure Static Web Apps]]></title>
            <link>https://www.pedrolamas.com/2020/05/22/my-first-steps-with-azure-static-web-apps/</link>
            <guid>https://www.pedrolamas.com/2020/05/22/my-first-steps-with-azure-static-web-apps/</guid>
            <pubDate>Fri, 22 May 2020 16:01:35 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/ce8f9779ec3e822bc5f490cbbdaf8273/pedrolamas-com-Azure-Static-Web-App.png" alt="My first steps with Azure Static Web Apps" class="webfeedsFeaturedVisual" /></p><p>Let me just start by saying that Build 2020 was awesome!!</p><p>There was a lot of great content going around for everyone, but as I was watching the <a href="https://mybuild.microsoft.com/sessions/898230c4-1350-4fc6-acba-6baf1a58d76a">“From code to scale! Build a static web app in minutes”</a> session showing how easy it is to use <a href="https://azure.microsoft.com/en-au/services/app-service/static/"><strong>Azure Static Web Apps</strong></a>, I couldn’t help but to try that for my own with this website!</p><p>My first attempt was to run through the <a href="https://docs.microsoft.com/en-au/azure/static-web-apps/publish-gatsby#deploy-your-web-app">“Tutorial: Publish a Gatsby site to Azure Static Web Apps Preview”</a>, and in the end I was happy to see it created the Azure resources and the a <a href="https://github.com/pedrolamas/pedrolamas.com/blob/azure-test/.github/workflows/azure-static-web-apps-jolly-ground-016a8c003.yml">new Github workflow</a> showed up on my repository.</p><p>On close analysis of the workflow, I can see there’s a new <code>Azure/static-web-apps-deploy</code> action in use doing all the heavy lifting! Internally, this action is using <a href="https://github.com/microsoft/Oryx">Oryx</a> build system to identify the type of source code in the repo and compile it.</p><p>Once the workflow started and got to the <code>Azure/static-web-apps-deploy</code> action, I quickly came to realize that it wasn’t happy with the fact that my “package.json” file had <code>&quot;yarn&quot;: &quot;&gt;=1.22&quot;</code> on the <code>&quot;engines&quot;</code> node… the build image only had yarn 1.17 and so the <a href="https://github.com/pedrolamas/pedrolamas.com/runs/698012520?check_suite_focus=true">build failed</a>:</p><pre><code class="language-text">error pedrolamas.com@0.1.0: The engine &quot;yarn&quot; is incompatible with this module. Expected version &quot;&gt;=1.22&quot;. Got &quot;1.17.3&quot;
error Found incompatible module.
</code></pre><p>At this point I edited my “package.json” file, lowered the yarn version requirement to “1.17”, and moved forward.</p><p>As expected, pushing this change caused a new workflow to start, but again, this <a href="https://github.com/pedrolamas/pedrolamas.com/runs/698023365?check_suite_focus=true">failed</a>:</p><pre><code class="language-text">error Processing /bin/staticsites/ss-oryx/app-int/content/assets/logo.jpg failed

Original error:
/bin/staticsites/ss-oryx/app-int/node_modules/cwebp-bin/vendor/cwebp: **error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory**
</code></pre><p>This time, the problem was a lot more complicated to fix: the libGL.so.1 library required by Gatsby to process the images was missing from the Oryx docker image!</p><p>At this stage I actually thought giving up and went to Twitter to somehow vent my frustration on what I just experienced:</p><blockquote class="twitter-tweet"><p lang="en" dir="ltr">I tried this yesterday with my own GatsbyJs website and unfortunately it failed... First it was Yarn version (had to lower my requirement), but once I fixed that it failed on some native component when processing the images. <a href="https://t.co/rnYuwtmYyj">https://t.co/rnYuwtmYyj</a></p>— Pedro Lamas (@pedrolamas) <a href="https://twitter.com/pedrolamas/status/1263505047150899201?ref_src=twsrc%5Etfw">May 21, 2020</a></blockquote> <script async="" src="https://platform.twitter.com/widgets.js" charSet="utf-8"></script><p><a href="https://twitter.com/John_Papa">John Papa</a> quickly replied to that tweet, and asked me to open an <a href="https://github.com/Azure/static-web-apps/issues/17">issue</a> on the <a href="https://github.com/Azure/static-web-apps">Azure Static Apps</a> repo.</p><p>After some messages exchanged, I followed up on <a href="https://github.com/Azure/static-web-apps/issues/17#issuecomment-632406729">a tip</a> from <a href="https://twitter.com/AnnajiGanti">Annaji Sharma Ganti</a> to compile the source code <strong>before</strong> the <code>Azure/static-web-apps-deploy</code> action, and make the action point to the compiled static folder (the “public” folder in my case) - this way Orix would just skip the compilation bit and go directly to publishing the artifacts to Azure.</p><p>You can see <a href="https://github.com/pedrolamas/pedrolamas.com/commit/b82fcbcef206da534f6e661521d2f91b452f24e2#diff-12cef35996238334e1b6c87f186fbda9">here</a> my changes to the workflow.</p><p>Finally, the workflow worked as expected and I could see my static GatsbyJs site hosted as an Azure Static Web App!</p><p>I then made a few more changes (like ensuring that GitHub would checkout the submodule with the website images and fixed some missing environment variables), added a custom domain, waited a few minutes for it to generate a valid SSL certificate, and… we are done!!</p><p><a href="http://azure-test.pedrolamas.com/">http://azure-test.pedrolamas.com/</a></p><p>I ran a website speed test with <a href="https://www.fastorslow.com/">Fast or Slow</a> and got <a href="https://www.fastorslow.com/app/profile/ca6be8e7-1db8-5e42-b92c-cdb5eff79857">98 of 100 points</a>, a <a href="https://www.fastorslow.com/app/profile/f2f146f8-11f5-5526-b14b-eca2d8e9b4ec">2 points improvement</a> over a speed test of this website (which is built and hosted on Netlify with Cloudflare CDN)</p><p><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:720px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:38.888888888888886%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAYAAAD5nd/tAAAACXBIWXMAAB2HAAAdhwGP5fFlAAABmUlEQVQoz02RXWsTURCG82M2ZL/Onj3n7GfALpKkf6n4BxTEHxAEqVCWQpEi1FwUBRHEgKLkpkibVglqjSDeiWDFR/bYJHsxzDAzPLzvTMfzPMbjMXVds39wwO7uQ9I0wfd9RCQQRiCkIJIRURQhhLD9KL6uhSAMw3XuBL5PXe+zc2uHvTv3eHU8o7q5heu6qEwxGA1sLoYlSZ6ilUanmnLYx2iDlHINbKLT7XZ5N5vxcbHg26fPzE/PKfslnu+hcs1oe4TKNPmwaAEN5XYfrbWNFcwCHcfhw8UFv6/+8BdYLi8pigLP9dBGowtD2oAKgzKKWMbWvikT4ji2kCAIrEprudfrcfz0OWenZ7w//8LsZE61dQM/CKyiNElJkgStFEqptSoVb2qTmvWNO6HvcvfBE27fP2Lv8QuOnk0ZDQc0z4qktEuraO4lo+ue3PSbulFqgV3H4WS+YPH9Fz9+XnH5dUlVVf+/3LpNY6extor2TIRiA2y++ejwkJfTKW/fvGYymZBlmQWsFDTLUsbkeUGe53beVt7e+wcgKzGWmLHR3QAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Speed test results from Fast or Slow for this Azure Static Web App" title="Speed test results from Fast or Slow for this Azure Static Web App" src="/static/2d9999e124c481cff6d0f651c10e5a3a/37523/pedrolamas-com-Azure-Static-Web-App-speed-test.png" srcSet="/static/2d9999e124c481cff6d0f651c10e5a3a/e9ff0/pedrolamas-com-Azure-Static-Web-App-speed-test.png 180w,/static/2d9999e124c481cff6d0f651c10e5a3a/f21e7/pedrolamas-com-Azure-Static-Web-App-speed-test.png 360w,/static/2d9999e124c481cff6d0f651c10e5a3a/37523/pedrolamas-com-Azure-Static-Web-App-speed-test.png 720w,/static/2d9999e124c481cff6d0f651c10e5a3a/302a4/pedrolamas-com-Azure-Static-Web-App-speed-test.png 1080w,/static/2d9999e124c481cff6d0f651c10e5a3a/07a9c/pedrolamas-com-Azure-Static-Web-App-speed-test.png 1440w,/static/2d9999e124c481cff6d0f651c10e5a3a/ad1ae/pedrolamas-com-Azure-Static-Web-App-speed-test.png 2270w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">Speed test results from Fast or Slow for this Azure Static Web App</figcaption>
  </figure></p><p>Took a bit more of effort than I initially expected, but I’m very happy and <strong>very impressed</strong> with the result!</p><p>The Azure Static Web Apps is currently in “preview” so be aware that changes and improvements will happen before it is ready for production - in the meantime, go and try it out for free!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microsoft Build 2020 registration is open, fully remote, and free!]]></title>
            <link>https://www.pedrolamas.com/2020/05/04/microsoft-build-2020/</link>
            <guid>https://www.pedrolamas.com/2020/05/04/microsoft-build-2020/</guid>
            <pubDate>Mon, 04 May 2020 17:07:13 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/2e3e1385bc41e32771ce64116f52cbed/Microsoft-Build-2020-Registration-is-Open-Fully-Remote-and-Free.png" alt="Microsoft Build 2020 registration is open, fully remote, and free!" class="webfeedsFeaturedVisual" /></p><p><a href="https://www.microsoft.com/build">Microsoft Build 2020</a>, the biggest annual event from Microsoft for Developers by developers, is just around the corner!</p><p>In regular times, <strong>//build/</strong> is an in-person paid event, but given the current situation with COVID-19, Microsoft announced that <strong>this year it will host the event virtually, and completely free!</strong></p><p>The event starts on the <time dateTime="2020-05-19T15:00:00Z">19th of May at 16:00 London time</time> with Satya Nadella, followed by 48h of live sessions!</p><p>You can register <a href="https://register.build.microsoft.com/">here</a> right now!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Windows Phone apps are now open-source!]]></title>
            <link>https://www.pedrolamas.com/2019/10/30/my-windows-phone-apps-are-now-open-source/</link>
            <guid>https://www.pedrolamas.com/2019/10/30/my-windows-phone-apps-are-now-open-source/</guid>
            <pubDate>Wed, 30 Oct 2019 10:52:10 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/038a8fb292f7996c614046d8860cc49d/open-source.png" alt="My Windows Phone apps are now open-source!" class="webfeedsFeaturedVisual" /></p><p>As Windows Phone has been <a href="/2017/07/10/windows-phone-is-officially-dead/">dead and buried</a> for a while now, last weekend I uploaded all assets and source-code for my old Windows Phone 7.x and 8.x apps to GitHub, some of them never before published!</p><p>Here’s the list of the new repos:</p><ul><li><a href="https://github.com/pedrolamas/PedroLamas.JogosSantaCasa">PedroLamas.JogosSantaCasa</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.OtherSide">PedroLamas.OtherSide</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.Quadratic">PedroLamas.Quadratic</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.TheBroCode">PedroLamas.TheBroCode</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.Vencimento">PedroLamas.Vencimento</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.WP7.CTTObjectos">PedroLamas.<abbr title="Windows Phone 7">WP7</abbr>.CTTObjectos</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.WP7.MetroNoPorto">PedroLamas.<abbr title="Windows Phone 7">WP7</abbr>.MetroNoPorto</a></li><li><a href="https://github.com/pedrolamas/PedroLamas.WP7.UnitConverter">PedroLamas.<abbr title="Windows Phone 7">WP7</abbr>.UnitConverter</a></li></ul><p>All content is available under MIT license, but please bear in mind that I’ve built these a while back and so I give no guaranties that these are in working order!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I've been up to lately!]]></title>
            <link>https://www.pedrolamas.com/2019/10/25/what-ive-been-up-to-lately/</link>
            <guid>https://www.pedrolamas.com/2019/10/25/what-ive-been-up-to-lately/</guid>
            <pubDate>Fri, 25 Oct 2019 16:32:23 GMT</pubDate>
            <content:encoded><![CDATA[<p>A few months ago, I decided to take a break from <abbr title="Universal Windows Platform">UWP</abbr> development, and since then I’ve been learning a lot of different technologies while working in new projects!</p><p>Don’t get me wrong here: I still love to work in <abbr title="Universal Windows Platform">UWP</abbr> and will carry on doing so, but reality is that it’s been getting a lot harder to find companies looking for <abbr title="Universal Windows Platform">UWP</abbr> experts to work.</p><p>At the same time, I believe there is nothing wrong with expanding your knowledge base by learning new stuff, so here we are!</p><p>Since learning React and TypeScript, I’ve fully <a href="/2019/07/30/migrated-from-jekyll-gatsby/">migrated this website from Jekyll to Gatsby</a>.</p><p>I enjoyed <a href="https://www.gatsbyjs.org/">Gatsby</a> so much that I have even contributed with a couple of <a href="https://github.com/gatsbyjs/gatsby/pulls?q=author%3APedroLamas"><abbr title="Pull Request">PR</abbr>’s</a> and created my first Gatsby Plugin <a href="https://www.npmjs.com/package/gatsby-remark-acronyms">gatsby-remark-acronyms</a> (this is also my first npm package ever)!</p><p>In my home I have a NanoPi NEO 2 <abbr title="Small Board Computer">SBC</abbr> running <a href="https://www.home-assistant.io/">Home Assistant</a> as an all-in-one home automation solution, so I’ve open-sourced my whole <a href="https://github.com/pedrolamas/home-assistant-config">configuration</a>, including the <a href="https://github.com/pedrolamas/nanopineo2-docker-config">Docker configuration</a> that hosts it.</p><p>This gave me the opportunity to improve my Python skills, and so I have already contributed back with a couple of <a href="https://github.com/home-assistant/home-assistant/pulls?q=author%3APedroLamas"><abbr title="Pull Request">PR</abbr>’s</a>.</p><p>There are a few more projects I’m involved on that I haven’t mentioned above, but the more I learn new stuff, the more I think I should make a change to the site description: ”<del>Windows</del> Development”…</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changing the default binding mode with x:DefaultBindMode]]></title>
            <link>https://www.pedrolamas.com/2019/08/16/changing-the-default-binding-mode-with-xdefaultbindmode/</link>
            <guid>https://www.pedrolamas.com/2019/08/16/changing-the-default-binding-mode-with-xdefaultbindmode/</guid>
            <pubDate>Fri, 16 Aug 2019 08:16:12 GMT</pubDate>
            <content:encoded><![CDATA[<p>On my <a href="/2015/10/19/compiled-bindings-considerations/">Compiled Bindings considerations</a> article, I wrote about the differences between regular bindings (<a href="https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/binding-markup-extension?wt.mc_id=MVP">Binding</a>) and the <abbr title="Universal Windows Platform">UWP</abbr> compiled bindings (<a href="https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-bind-markup-extension?wt.mc_id=MVP">x:Bind</a>).</p><p>The most important bit to keep from that article is the fact that the default binding <code>Mode</code> for regular bindings is <code>OneWay</code>, while for the compiled ones is <code>OneTime</code>.</p><p>Best way to understand this is with some sample code:</p><pre><code class="language-xml">&lt;StackPanel&gt;
    &lt;!-- the implicit binding mode here is &quot;OneWay&quot; --&gt;
    &lt;TextBlock Text={Binding Name} /&gt;

    &lt;!-- the implicit binding mode here is &quot;OneTime&quot; --&gt;
    &lt;TextBlock Text={x:Bind Name} /&gt;
&lt;/StackPanel&gt;
</code></pre><p>Starting Windows 10 version 1607 (Anniversary Update, <abbr title="Software Development Kit">SDK</abbr> version 14393), developers can change the default binding <code>Mode</code> by setting the <a href="https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-defaultbindmode-attribute?wt.mc_id=MVP">x:DefaultBindMode</a> attribute.</p><p>Applying the attribute to an element will make it and all child elements use the same value for binding mode.</p><p>Here’s the same sample code again, now with the <code>x:DefaultBindMode</code> attribute added to the root element:</p><pre><code class="language-xml">&lt;StackPanel x:DefaultBindMode=&quot;OneWay&quot;&gt;
    &lt;!-- the implicit binding mode here is &quot;OneWay&quot; --&gt;
    &lt;TextBlock Text={Binding Name} /&gt;

    &lt;!-- the implicit binding mode here is &quot;OneWay&quot;, as set on the x:DefaultBindMode in the parent element --&gt;
    &lt;TextBlock Text={x:Bind Name} /&gt;
&lt;/StackPanel&gt;
</code></pre>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrated from Jekyll to Gatsby]]></title>
            <link>https://www.pedrolamas.com/2019/07/30/migrated-from-jekyll-gatsby/</link>
            <guid>https://www.pedrolamas.com/2019/07/30/migrated-from-jekyll-gatsby/</guid>
            <pubDate>Tue, 30 Jul 2019 17:24:22 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/cd7e40d94096093b0d8481d89c657114/Migrated-from-Jekyll-to-Gatsby.png" alt="Migrated from Jekyll to Gatsby" class="webfeedsFeaturedVisual" /></p><p>For the last couple of months, I’ve been working a lot on something quite different from my Windows Development expertise: writing .NET Core micro-services with React and Typescript front-end, running on Docker containers in Kubernetes, hosted on Microsoft Azure!</p><p>The thing is that the more I worked with React and Typescript, the more I was enjoying it — to the point that made me think on how I could use my new skills on this blog!</p><p>Back in 2017, I <a href="/2017/03/13/migrated-from-wordpress-to-jekyll">migrated my blog from WordPress to Jekyll</a> and hosted on <a href="https://pages.github.com">GitHub Pages</a>.</p><p>From that moment my blog became blazing fast and I was fairly happy with the arrangement; plus, as far as I am aware, I had near-zero downtime on the blog!</p><p>However, I always felt that Jekyll in GitHub Pages was quite limited in what can be achieved (a simple example is that you can’t easily generate a page with all categories or tags).</p><p>I started to search for a React-based static site generator, and that’s how I found <a href="https://gatsbyjs.com">Gatsby</a>!</p><blockquote><p>Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps</p></blockquote><p>A month ago, I started to migrate the blog and today it is all Gatsby based, fully hosted on <a href="https://www.netlify.com">Netlify</a> (provides free hosting, highly configurable build configuration, custom headers, redirect rules, …)</p><p>This very post if the first of many using the new platform!</p><p>As far as I can tell, everything is working properly, but if you find any problem, please report it by <a href="https://github.com/pedrolamas/pedrolamas.com/issues/new">creating a new issue</a> and I’ll take care of it as soon as possible!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Insider Dev Tour London]]></title>
            <link>https://www.pedrolamas.com/2019/06/06/insider-dev-tour-london/</link>
            <guid>https://www.pedrolamas.com/2019/06/06/insider-dev-tour-london/</guid>
            <pubDate>Thu, 06 Jun 2019 10:10:12 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/39399deae7cffc10d524e94a60c5c654/Insider-Dev-Toor-London.png" alt="Insider Dev Tour London" class="webfeedsFeaturedVisual" /></p><p>Microsoft is hosting the Insider Dev Tour London on <strong>June 18th, 2019</strong> from 8:00 to 17:30 at the <a href="https://goo.gl/maps/BLWkFPbfqFpjMV748">Vue Cinema in Leiceiter Square</a>.</p><p>You can expect a lot of content around building Microsoft 365 experiences (Windows, Graph, Office, Teams), no matter your skill as a developer.</p><p>I will be there to talk about <strong>“Developing with the new Edge Browser”</strong>, and there will be quite a few familiar faces talking about other topics too!</p><p>More details and registration are available <a href="https://developer.microsoft.com/en-us/windows/campaigns/uk-london">here</a>!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making the case for XAML Markup Extensions]]></title>
            <link>https://www.pedrolamas.com/2019/03/31/making-the-case-for-xaml-markup-extensions/</link>
            <guid>https://www.pedrolamas.com/2019/03/31/making-the-case-for-xaml-markup-extensions/</guid>
            <pubDate>Sun, 31 Mar 2019 16:23:05 GMT</pubDate>
            <content:encoded><![CDATA[<p>Consider the following code:</p><pre><code class="language-xml">&lt;AppBarButton Content=&quot;Send&quot; Icon=&quot;Send&quot; /&gt;
</code></pre><p>In the above example, the <code>AppBarButton.Icon</code> property above is set to “Send” which is actually a value of the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.symbol?wt.mc_id=MVP">Symbol</a> enumeration.</p><p>The <code>Symbol</code> enumeration is quite useful to quickly access glyphs from the Segoe MDL2 Assets font file, but this is a limited subset; a more complete list of the available glyphs can be found <a href="https://docs.microsoft.com/en-us/windows/uwp/design/style/segoe-ui-symbol-font?wt.mc_id=MVP">here</a>.</p><p>If you want to use one of the symbols from that list that is not part of the <code>Symbol</code> enumeration, you need to escape the unicode point by prefixing it with ”&amp;#x” and suffixing with ”;“.</p><p>For example, the unicode point for the “WindowsInsider” (Ninja Cat) glyph is “F1AD”, so the complete escaped code is ”&amp;#xF1AD;”</p><p>In an ideal world, one would just use it like this:</p><pre><code class="language-xml">&lt;!-- this doesn&#x27;t work! --&gt;
&lt;AppBarButton Content=&quot;Ninja Cat&quot; Icon=&quot;&amp;#xF1AD;&quot; /&gt;
</code></pre><p>However, you will quickly realize that this doesn’t work!</p><p>The correct way is by using the <code>FontIcon</code> class and specifying both the font family name and the escaped glyph unicode point:</p><pre><code class="language-xml">&lt;!-- this works! --&gt;
&lt;AppBarButton Content=&quot;Ninja Cat&quot;&gt;
  &lt;AppBarButton.Icon&gt;
    &lt;FontIcon FontFamily=&quot;Segoe MDL2 Assets&quot; Glyph=&quot;&amp;#xF1AD;&quot; /&gt;
  &lt;/AppBarButton.Icon&gt;
&lt;/AppBarButton&gt;
</code></pre><h2>MarkupExtension to the rescue!</h2><p>Introduced in Windows 10 Fall Creators Update (v10.0.16299.0), the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.markup.markupextension?wt.mc_id=MVP">MarkupExtension</a> class allows developers to write markup shortcodes just like the native <code>{Binding}</code>, <code>{StaticResource}</code>, or <code>{x:Bind}</code>.</p><p>To create a <abbr title="Extensible Application Markup Language">XAML</abbr> markup extension, create a new class and ensure that it:</p><ul><li>inherits from <code>MarkupExtension</code></li><li>overrides the <code>MarkupExtension.ProvideValue</code> to provide the implementation</li><li>is marked with the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.markup.markupextensionreturntypeattribute?wt.mc_id=MVP">MarkupExtensionReturnTypeAttribute</a> and specifies the return type</li><li>has a name ending in “Extension”.</li></ul><p>Following on our example, we can easily create a <code>MarkupExtension</code> that would return a <code>FontIcon</code> instance for a given glyph unicode point:</p><pre><code class="language-csharp">[MarkupExtensionReturnType(ReturnType = typeof(FontIcon))]
public class FontIconExtension : MarkupExtension
{
    public string Glyph { get; set; }

    protected override object ProvideValue()
    {
        return new FontIcon()
        {
            Glyph = Glyph,
            FontFamily = new FontFamily(&quot;Segoe MDL2 Assets&quot;)
        };
    }
}
</code></pre><p>Having this on our code, we can then use it in <abbr title="Extensible Application Markup Language">XAML</abbr> just like this:</p><pre><code class="language-xml">&lt;!-- this works just fine! --&gt;
&lt;AppBarButton Icon=&quot;{local:FontIcon Glyph=&#x27;&amp;#xF1AD;&#x27;}&quot; /&gt;
</code></pre><p>In the end, we went from 5 lines of <abbr title="Extensible Application Markup Language">XAML</abbr> code to just 1!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows 10 Mobile Emulator fails to start with 0x800705AA error]]></title>
            <link>https://www.pedrolamas.com/2019/01/15/windows-10-mobile-emulator-fails-to-start-with-0x800705AA-error/</link>
            <guid>https://www.pedrolamas.com/2019/01/15/windows-10-mobile-emulator-fails-to-start-with-0x800705AA-error/</guid>
            <pubDate>Tue, 15 Jan 2019 16:55:05 GMT</pubDate>
            <content:encoded><![CDATA[<p>I recently moved to a new machine and while attempting to debug a <abbr title="Universal Windows Platform">UWP</abbr> app in the Windows 10 Mobile emulator, I came across the following error message:</p><p><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:558px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:558px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:56.111111111111114%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB0klEQVQoz2WQa6+bMAyG+f+/aPs0TTsfdpF6uIUQaLuecifkCiEhgXaiPZt0NMuyXlu2/NjelaqKiLrphdL2dl+2u/3Pl/UpbsZt2u5u160dnce/fNI/vyq3TVIuxqhpMnpW06TGaVZKz0rPszFaK2WtvT/s9ohMr5748WLCXy1l18u1rqqyKOuqrqq6qZu6qsuiLIuyqZvirWibdhxHzjljfJRiGK1ntrtdTBSEwasf+GEUxUkEEpC8Hl7TJL2+FQMeFmNmrfU863lWasfSaiKT9YzdNmcJHgQXlDIhBBkIoRQPgxBiMcZZu65udc5a65zbts259R3brPfVWQgSlGY5QhDCLMsgTFGKTvkxDkP/4CcAhH6E0hTEAMQgDKJRCqLcc9ghmCKUQ7ADZylCKMtSlGVZ4AcwgU3dUEp3KELatqWMjYK3bPaMu922ta0bMpC+63GPu67DGOMeU0r7rmu7bj9jIIwxzpiUcsCEEdIw9Y59yo/n0/n4iJfz5ZifcpRnKYIggQDGUQwTCGECYhCF0eX82xnNZucJZRZjGKWcMUqplHJfQBlj+/OexjmXUj4FZawjYhDTBU9eg6ngH/o+6L/pvzoX8nt8/vxy+BYXfwBF+14slEXZdgAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="0x800705AA error message" title="0x800705AA error message" src="/static/a03b825f53128cf0be7453b9ff91805d/42a8d/0x800705AA-error-message.png" srcSet="/static/a03b825f53128cf0be7453b9ff91805d/e9ff0/0x800705AA-error-message.png 180w,/static/a03b825f53128cf0be7453b9ff91805d/f21e7/0x800705AA-error-message.png 360w,/static/a03b825f53128cf0be7453b9ff91805d/42a8d/0x800705AA-error-message.png 558w" sizes="(max-width: 558px) 100vw, 558px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">0x800705AA error message</figcaption>
  </figure></p><p>I couldn’t find any information on this 0x800705AA error, but I eventually tracked this to be caused by the fact Hyper-V was using the machine <abbr title="Graphical Processing Unit">GPU</abbr> with RemoteFX!</p><p>The easiest way to fix this I found was to just disable RemoteFX; to do so, follow these steps:</p><ul><li>open Hyper-V Manager (just press <kbd>Win+R</kbd>, type <code>virtmgmt.msc</code> and hit Enter)</li><li>on the left pane, right-click the machine name and then click “Hyper-V Settings”</li><li>on the tree, select “Physical GPUs”</li><li>untick “Use this <abbr title="Graphical Processing Unit">GPU</abbr> with RemoteFX” and click OK</li></ul><p><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:720px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:95%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAIAAAAf7rriAAAACXBIWXMAAAsTAAALEwEAmpwYAAACfElEQVQ4y42T23KbOhRA+f+fKnTmOKG1j52mjWNhkEASF0nowkUIm5oOdtKTTk5mumY/6GGv0b5IHuWmYpwWTJrOjufenXp3GsbzcJp6d34frR274dT0znTWg6SKcFlyxYVUptWmq6U6wPR4PBKMq4VyoSjK8r8oiryuhVdJKSSNYpgRYp2z49i5MUboYfeAUAoRghBmaUYIyTAmhBJCMCY5zbXWXhEdk6f99sv+aXdgRyghMknMi+IYRUkcx8fj8/45y7KqYmVZsYpda2Gc80XG3348/rPd+OvH1QN6iGQE2/1ThgmTqlZKaC2bRipV/4kQQkrpVVIxXhQwKVN0sv08z0PXpV+//vD9fRDsgyBZrQpK8z+hlAohvLKWWFCMSYpxRmhnrbM2D0MQfM43m2K75ZtNq3XbdW3bNq/oKx4qJawaVivVdEKaphs661KMV3d3+wPABMM0i5MEXsEYZxlGKH3puaxNXooEIlHLrreXy2ztQClZr9eP378vA4eLmSQwiWPGmBCCcy6lvMkyY3m2JMGqqi7zxTmHIPQ/+eF9CABgnDdN014xr2itlVJeKRURJcmWHY7jOM+zcy5F6Wp1d38f3t+F6/U6L0pjjFJKv2GRuTTn6dy2bd/30zQt0x4GjPF2u9vtdhhjeUW/40We5/lyucyvOOfiOPb9wPeD4FMQhl8QQn8rD8OQ5/nhAAAAh+fnCAAhxN/Kfd8rpa57vW23vU3oPf8jW2ullOoN+gM+lN8mGaNvd/8u4XbwuNQ/f06n0+l8ZZqmruveylIpxgUXdS0lY/z2MW7vxGO1Mh9UpbRujM5KGT6l/wIKSREBQAillAIAqor9AlhHFSdBvKqqAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Hyper-V Settings updated" title="Hyper-V Settings updated" src="/static/a2fd1dc4005cd2225413d429d16cd7b3/37523/Hyper-V-Settings-updated.png" srcSet="/static/a2fd1dc4005cd2225413d429d16cd7b3/e9ff0/Hyper-V-Settings-updated.png 180w,/static/a2fd1dc4005cd2225413d429d16cd7b3/f21e7/Hyper-V-Settings-updated.png 360w,/static/a2fd1dc4005cd2225413d429d16cd7b3/37523/Hyper-V-Settings-updated.png 720w,/static/a2fd1dc4005cd2225413d429d16cd7b3/d44c9/Hyper-V-Settings-updated.png 722w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">Hyper-V Settings updated</figcaption>
  </figure></p><p>After disabling RemoveFX, remove any Windows 10 Mobile emulator from the “Virtual Machines” list (Visual Studio will re-create these) and just deploy from Visual Studio again and you should now be able to launch the emulator!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Start Strong-Naming your Assemblies!]]></title>
            <link>https://www.pedrolamas.com/2018/09/11/start-strong-naming-your-assemblies/</link>
            <guid>https://www.pedrolamas.com/2018/09/11/start-strong-naming-your-assemblies/</guid>
            <pubDate>Tue, 11 Sep 2018 15:25:01 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/6b1affa3d27e180c506e1cf6b57c88db/Keep-Calm-And-Strong-Name-Assemblies.png" alt="Start Strong-Naming your Assemblies!" class="webfeedsFeaturedVisual" /></p><h2><abbr title="Too Long">TL</abbr>;<abbr title="Didn&#x27;t Read">DR</abbr></h2><p>My opinion on this subject has evolved to the point I’m now recommending that you should strong-name your assemblies.</p><h2>Why the change of heart?</h2><p>2 years ago, I wrote my thoughts about strong-naming assemblies in a post I called <a href="/2016/03/01/still-strong-naming-your-assemblies-you-do-know-its-2016-right/">“Still Strong-Naming your Assemblies? You do know it’s 2016, right?”</a>.</p><p>Coming from all the development related pains in Silverlight and Windows Phone platforms, I knew how strong-named assemblies were a real problem, hence why I wrote that post and said that developers should stop strong-naming their assemblies.</p><p>With time, that post somehow became the “canonical answer” for questions in the line of “should I strong-name my assemblies?“.</p><blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">This would make a good blog post title. There is a lot of confusion in the community on why or why not assemblies should have strong names in 2018! This is still very often cited as the canonical answer all over the place: <a href="https://t.co/RblHqL4h48">https://t.co/RblHqL4h48</a></p>— bit bonk (@bitbonk) <a href="https://twitter.com/bitbonk/status/1037077132810366976?ref_src=twsrc%5Etfw">September 4, 2018</a></blockquote><script async="" src="https://platform.twitter.com/widgets.js" charSet="utf-8"></script><p>Coming to more recent times, I had the chance to revisit this topic while discussing what to do over a strong-naming related <a href="https://github.com/Microsoft/WindowsCommunityToolkit/issues/2198">issue</a> on the <a href="https://github.com/Microsoft/WindowsCommunityToolkit">Windows Community Toolkit</a>.</p><p>After the discussion and a few quick checks to confirm the information passed, the consensus was to go ahead and strong-name the toolkit assemblies.</p><p>Since that moment, I must admit that I changed my mind and I’m now advocating that <strong>you should strong-name your assemblies!</strong></p><h2>Silverlight and Windows Phone are dead</h2><p>For much that hurts me to say this(!), Silverlight and Windows Phone are dead platforms and thus, the reasoning to not strong-name an assembly as they could become unusable in these platforms, is no longer valid.</p><h2>Modern frameworks can ignore strong-name information</h2><p>While Windows 10 <abbr title="Universal Windows Platform">UWP</abbr> and Xamarin completely ignore any strong-name information in the referenced assemblies, .NET Core has mechanisms to automatically redirect all references.</p><p>In fact, .NET Core enforces all their assemblies to be strong-named (they even have a <a href="https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/strong-name-signing.md">document</a> describing this requirement).</p><p>NuGet does help by automatically creating binding redirections when you add packages to your project!</p><h2>The <abbr title="Global Assembly Cache">GAC</abbr> is still very well alive</h2><p>Yes, against what I thought to be true, Windows 10 still has a <abbr title="Global Assembly Cache">GAC</abbr> that supports side-by-side assemblies for the full .NET Framework!</p><p>The <abbr title="Global Assembly Cache">GAC</abbr> requires strong-named assemblies, so there is still a real use case for those in modern days.</p><h2>Final thoughts</h2><p>I’m taking a leap of faith that all currently supported frameworks and all future ones will provide mechanisms to ignore strong-name info in assemblies, or just allow to use redirections.</p><p>If that proves true, then yes: you should strong-name your assemblies as that will allow more people to use them.</p><p>To those still skeptical of strong-naming their assemblies, I propose a compromise solution: do strong-name your assemblies, but only increment the assembly version for major releases! <a href="https://www.newtonsoft.com/json">Json.NET</a> has been using this approach to avoid binding redirects since 2014, and as far as I can tell, with relative success!</p><p>As a final note to open-source library developers, <em>I strongly recommend that the strong-name key file gets check-in to the project repository</em> so that anyone can easily clone the project and compile a version of the library that works with anyone else’s binaries!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building multi-window dispatcher agnostic view-model]]></title>
            <link>https://www.pedrolamas.com/2018/04/19/building-a-multi-window-dispatcher-agnostic-view-model/</link>
            <guid>https://www.pedrolamas.com/2018/04/19/building-a-multi-window-dispatcher-agnostic-view-model/</guid>
            <pubDate>Thu, 19 Apr 2018 20:19:43 GMT</pubDate>
            <content:encoded><![CDATA[<p>On my earlier post I wrote about <a href="/2018/03/23/building-a-dispatcher-agnostic-view-model/">“Building a dispatcher agnostic view-model”</a>; that was just laying the ground for this follow up post, where I am going to show how we can extend that knowledge to use view-models shared between separate windows on different <abbr title="User Interface">UI</abbr> threads!</p><p>In truth, I started thinking in writing this after seeing my fellow <abbr title="Most Valuable Professional">MVP</abbr> <a href="http://www.rudyhuyn.com/">Rudy Huyn</a> <a href="https://github.com/rudyhuyn/xUIBinding">CrossUIBinding</a> library.</p><blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Nice, but wouldn&#x27;t it be easier just to override the add &amp; remove of the PropertyChanged event and capture the Dispatcher there? That way all you need is a base viewmodel, no other changes on the view or properties of the viewmodel!</p>— Pedro Lamas (@pedrolamas) <a href="https://twitter.com/pedrolamas/status/974710901776535558?ref_src=twsrc%5Etfw">March 16, 2018</a></blockquote><script async="" src="https://platform.twitter.com/widgets.js" charSet="utf-8"></script><p>Rudy’s solution to this problem requires a wrapper around the properties of the view-models, where as I intend to fix the way view-models notify their event handlers.</p><h2>But why do I need this?</h2><p>Well, you will only need this if your application uses multiple windows <strong>and</strong> you want to share the same view-model instance between them!</p><p>if that is the case, then you must ensure you raise the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.data.inotifypropertychanged.propertychanged?wt.mc_id=MVP">INotifyPropertyChanged.PropertyChanged</a> event on the correct thread as <strong>each window as its own separate <abbr title="User Interface">UI</abbr> thread!</strong></p><p>I strongly recommend a look at the great document that Rudy has written around the <a href="https://github.com/rudyhuyn/xUIBinding/blob/master/README.md">CrossUIBinding</a> as it has a lot of valuable information with some great visualizations!</p><h2>So how do we solve this?</h2><p>We can ensure we raise the <code>PropertyChanged</code> event in the correct <abbr title="User Interface">UI</abbr> thread by capturing the dispatcher instance when an event handler is added!</p><p>That can easily be achieved by defining custom <code>add</code> and <code>remove</code> event accessors that will get invoked when client code subscribes and unsubscribes respectively to the event:</p><pre><code class="language-csharp">public abstract class MultiWindowBaseViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    {
        add
        {
            // add code goes here
        }
        remove
        {
            // remove code goes here
        }
    }
}
</code></pre><p>All we now need is to ensure we capture the <code>CoreDispatcher</code> when the <code>add</code> method runs, and store that with the handler reference.</p><p>After my first post, Daniel Vistisen correctly pointed out that we can use SynchronizationContext instead of CoreDispatcher thus making the whole thing .NET Standard compliant:</p><blockquote class="twitter-tweet" data-conversation="none" data-lang="en"><p lang="en" dir="ltr">Why not just use SynchronizationContext? Works with .netstandard</p>— Daniel Vistisen (@DanielVistisen) <a href="https://twitter.com/DanielVistisen/status/979140409518641152?ref_src=twsrc%5Etfw">March 28, 2018</a></blockquote><script async="" src="https://platform.twitter.com/widgets.js" charSet="utf-8"></script><p>He is absolutely right, so that is what we will now do!</p><p>We will use a <code>Dictionary&lt;SynchronizationContext, PropertyChangedEventHandler&gt;</code> to keep a collection of event handlers for each <code>SynchronizationContext</code>.</p><p>In the end, this is what I got to:</p><pre><code class="language-csharp">public class MultiWindowViewModelBase : INotifyPropertyChanged
{
    private readonly object _lock = new object();
    private readonly Dictionary&lt;SynchronizationContext, PropertyChangedEventHandler&gt; _handlersWithContext = new Dictionary&lt;SynchronizationContext, PropertyChangedEventHandler&gt;();

    public event PropertyChangedEventHandler PropertyChanged
    {
        add
        {
            if (value == null)
            {
                return;
            }

            var synchronizationContext = SynchronizationContext.Current;

            lock (_lock)
            {
                if (_handlersWithContext.TryGetValue(synchronizationContext, out PropertyChangedEventHandler eventHandler))
                {
                    eventHandler += value;

                    _handlersWithContext[synchronizationContext] = eventHandler;
                }
                else
                {
                    _handlersWithContext.Add(synchronizationContext, value);
                }
            }
        }
        remove
        {
            if (value == null)
            {
                return;
            }

            var synchronizationContext = SynchronizationContext.Current;

            lock (_lock)
            {
                if (_handlersWithContext.TryGetValue(synchronizationContext, out PropertyChangedEventHandler eventHandler))
                {
                    eventHandler -= value;

                    if (eventHandler != null)
                    {
                        _handlersWithContext[synchronizationContext] = eventHandler;
                    }
                    else
                    {
                        _handlersWithContext.Remove(synchronizationContext);
                    }
                }
            }
        }
    }

    protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        KeyValuePair&lt;SynchronizationContext, PropertyChangedEventHandler&gt;[] handlersWithContext;

        lock (_lock)
        {
            handlersWithContext = _handlersWithContext.ToArray();
        }

        var eventArgs = new PropertyChangedEventArgs(propertyName);

        foreach (var handlerWithContext in handlersWithContext)
        {
            var synchronizationContext = handlerWithContext.Key;
            var eventHandler = handlerWithContext.Value;

            synchronizationContext.Post(o =&gt; eventHandler(this, eventArgs), null);
        }
    }
}
</code></pre><p>Now all we need is to ensure that any view-model used on multiple windows, inherits from this base class.</p><p>Here’s a really simple example:</p><pre><code class="language-csharp">public class MainViewModel : MultiWindowViewModelBase
{
    private string _text;

    public string Text
    {
        get { return _text; }
        set
        {
            if (_text == value) return;

            _text = value;
            OnPropertyChanged();
        }
    }
}
</code></pre><h2>Final thoughts</h2><p>The <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.viewmanagement.applicationview.consolidated?wt.mc_id=MVP">ApplicationView.Consolidated</a> event should be monitored to allow for proper cleaning, so that no memory leaks occur.</p><p>Here’s an example of how this can be achieved:</p><pre><code class="language-csharp">public sealed partial class MainPage : Page
{
    public MainViewModel ViewModel =&gt; App.MainViewModel;

    public MainPage()
    {
        DataContext = ViewModel;

        this.InitializeComponent();

        ApplicationView.GetForCurrentView().Consolidated += ApplicationView_OnConsolidated;
    }

    private void ApplicationView_OnConsolidated(ApplicationView s, ApplicationViewConsolidatedEventArgs e)
    {
        if (e.IsAppInitiated || e.IsUserInitiated)
        {
            s.Consolidated -= ApplicationView_OnConsolidated;

            DataContext = null;

            // this is only required if you are using compiled bindings (x:Bind)
            Bindings.StopTracking();
        }
    }
}
</code></pre><p>I’ve also made available a <a href="https://github.com/pedrolamas/MultiWindowViewModelSample">full sample on GitHub</a> so you can see and test the whole solution! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a dispatcher agnostic view-model]]></title>
            <link>https://www.pedrolamas.com/2018/03/23/building-a-dispatcher-agnostic-view-model/</link>
            <guid>https://www.pedrolamas.com/2018/03/23/building-a-dispatcher-agnostic-view-model/</guid>
            <pubDate>Fri, 23 Mar 2018 19:06:43 GMT</pubDate>
            <content:encoded><![CDATA[<p>If you are writing multithread Windows apps (and if you are not, you should!), you know by now that any code related to the <abbr title="User Interface">UI</abbr> <strong>must</strong> run in the main thread (also called <abbr title="User Interface">UI</abbr> thread).</p><p>Knowing this, please look at the following view-model:</p><pre><code class="language-csharp">// Basic implementation of the INotifyPropertyChanged interface

public abstract class BaseViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

// The main view-model

public class MainViewModel : BaseViewModel
{
    private string _result;

    public string Result
    {
        get { return _result; }
        set
        {
            _result = value;
            OnPropertyChanged(&quot;Result&quot;);
        }
    }

    public async Task RetrieveData()
    {
        var data = await GetDataFromSomeWebsite()
            .ConfigureAwait(false);

        Result = data;
    }

    // More code will go here...
}
</code></pre><p>The <code>BaseViewModel</code> is just a basic implementation of the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.data.inotifypropertychanged?wt.mc_id=MVP">INotifyPropertyChanged</a> interface with a helper method that will raise the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.data.inotifypropertychanged.propertychanged?wt.mc_id=MVP">PropertyChanged</a> event - all quite standard for any <abbr title="Model View ViewModel">MVVM</abbr> based application!</p><p>Now let us say that in the view we have a TextBox control, and that the <code>Text</code> property is binded to the <code>MainViewModel.Result</code> property.</p><p>Given this, you will probably notice a problem with the <code>MainViewModel.RetrieveData</code> method: after awaiting the call to <code>GetDataFromSomeWebsite</code> method, most likely we will not be on the <abbr title="User Interface">UI</abbr> thread due to the <code>.ConfigureAwait(false)</code> (if you dont know what <code>ConfigureAwait</code> is, please read <a href="/2017/11/15/code-tips-to-keep-the-ui-responsive/">this post</a>). So, when we set the <code>Result</code> property on the next line which in turn will notify the <abbr title="User Interface">UI</abbr> that the property value has changed, that will cause an exception!</p><p>To fix it, we can use <code>CoreApplication.MainView.Dispatcher</code> to retrieve a <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.core.coredispatcher?wt.mc_id=MVP">CoreDispatcher</a> instance that will then allow us to execute code in the <abbr title="User Interface">UI</abbr> thread.</p><p>With some minor changes, the <code>MainViewModel.RetrieveData</code> method now looks something like this:</p><pre><code class="language-csharp">public async Task RetrieveData()
{
    var data = await GetDataFromSomeWebsite()
        .ConfigureAwait(false);

    CoreApplication.MainView.Dispatcher(CoreDispatcherPriority.Normal, () =&gt;
    {
        Text = data;
    });
}
</code></pre><p>For small view-models this approach is perfectly fine, but for bigger ones where multiple developers are working on, you might end up losing track of which properties you need to update in the <abbr title="User Interface">UI</abbr> thread and the ones you do not.</p><p><strong>Wouldn’t it be great if you just didn’t have to worry about this?</strong></p><p>To make our view-models completely oblivious of what is the current thread, we will need to make some changes to their base view-model!</p><p>The easiest way will be to capture the <code>CoreDispatcher</code> at start, and on the <code>OnPropertyChanged</code> method (or whatever you called your <code>PropertyChanged</code> event raising helper method), check if we need to dispatch the call or just raise the property regularly.</p><p>Here is our new and improved <code>BaseViewModel</code>:</p><pre><code class="language-csharp">public abstract class DispatcherAgnosticBaseViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private CoreDispatcher _dispatcher = CoreApplication.MainView.Dispatcher;

    protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        if (_dispatcher.HasThreadAccess)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        else
        {
            _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =&gt;
            {
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            });
        }
    }
}
</code></pre><p>Notice that the first this we do is to check the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.core.coredispatcher.hasthreadaccess?wt.mc_id=MVP">CoreDispatcher.HasThreadAccess</a> property; this property will return true if we are now on the <abbr title="User Interface">UI</abbr> thread, or false if we are not.</p><p>If we are, we can just raise the <code>PropertyChanged</code> event directly, but when we are not, we will do it by dispatching the call through the <abbr title="User Interface">UI</abbr> thread.</p><p>Now all we now need is to have every single view-model to inherit from this base class and we will never have to worry again about the dispatcher!</p><p>Well… not interely accurate, but I’ll leave that for another post ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiled Bindings considerations III]]></title>
            <link>https://www.pedrolamas.com/2018/01/31/compiled-bindings-considerations-iii/</link>
            <guid>https://www.pedrolamas.com/2018/01/31/compiled-bindings-considerations-iii/</guid>
            <pubDate>Wed, 31 Jan 2018 23:32:14 GMT</pubDate>
            <content:encoded><![CDATA[<p>Two years since my <a href="/2016/01/08/compiled-bindings-considerations-ii/">Compiled Bindings considerations II</a> article, I can finally write a part III that actually comes with some good news!</p><p>The earlier article focused on a really nasty bug with the compiled bindings ignoring the FallbackValue when the binding path didn’t resolve.</p><p>It now seems that Microsoft finally fixed this bug on the <a href="https://blogs.windows.com/buildingapps/2018/01/17/windows-10-sdk-preview-build-17069-now-available">Windows 10 <abbr title="Software Development Kit">SDK</abbr> Preview Build 17069</a>, and this fix will eventually make it’s way to the next stable release of the Windows 10 <abbr title="Software Development Kit">SDK</abbr>!</p><p>There is, however, a small requirement to make this work: the compiled binding expression <strong>must</strong> have the <code>FallbackValue</code> set.</p><p>To better understand it, please check this line of code taken from the example in the part II article:</p><pre><code class="language-xml">&lt;TextBlock Style=&quot;{StaticResource BodyTextBlockStyle}&quot; Text=&quot;{x:Bind ViewModel.CurrentTime.CurrentTimeTicks, Mode=OneWay}&quot; /&gt;
</code></pre><p>On the above, we will now add <code>FallbackValue={x:Null}</code> to the binding expression:</p><pre><code class="language-xml">&lt;TextBlock Style=&quot;{StaticResource BodyTextBlockStyle}&quot; Text=&quot;{x:Bind ViewModel.CurrentTime.CurrentTimeTicks, Mode=OneWay, FallbackValue={x:Null}}&quot; /&gt;
</code></pre><p>This will ensure that this TextBlock gets the text cleared when the binding can’t resolve the path or source!</p><p>A classic binding does this by default (when <code>FallbackValue</code> isn’t set, it will just use <code>null</code>), but for compiled bindings, we need to specify a value.</p><p>More “hard work”, but a solution to the problem, nevertheless!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code tips to keep the UI responsive]]></title>
            <link>https://www.pedrolamas.com/2017/11/15/code-tips-to-keep-the-ui-responsive/</link>
            <guid>https://www.pedrolamas.com/2017/11/15/code-tips-to-keep-the-ui-responsive/</guid>
            <pubDate>Wed, 15 Nov 2017 22:26:05 GMT</pubDate>
            <content:encoded><![CDATA[<p>I have taken a break from <abbr title="Universal Windows Platform">UWP</abbr> development, and for the last couple of weeks I have been working mostly on WPF projects.</p><p>You know, that “old” <abbr title="Extensible Application Markup Language">XAML</abbr> technology that started back when Windows XP was still a thing!</p><p>The interesting bit is that all my previous experience developing for Windows Phone did give me a lot of knowledge on how to write performant non-blocking code - and I am still learning something new every day!</p><p>These are some of my personal coding tips to help keep your app as responsive as possible!</p><h2>Execute CPU bound code on a separate thread</h2><p>Consider the following example:</p><pre><code class="language-csharp">private void CalculateButton_OnClick(object sender, RoutedEventArgs e)
{
    var total = MyLongRunningOperation();

    ResulTextBlock.Text = total.ToString();
}
</code></pre><p>The above code sample will run on the <abbr title="User Interface">UI</abbr> thread, and as it takes a while to run the <code>MyLongRunningOperation</code> method, it will make the app unresponsive until it finishes.</p><p>This is a perfect example of what CPU bound code is: code that should execute on a separate thread as to avoid blocking the <abbr title="User Interface">UI</abbr> thread while it runs.</p><p>There are a few ways to fix this problem and the easiest one is to just use <a href="https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.run?view=netcore-2.0&amp;wt.mc_id=MVP">Task.Run</a>.</p><p>Now look at this alternative:</p><pre><code class="language-csharp">private async void CalculateButton_OnClick(object sender, RoutedEventArgs e)
{
    var total = await Task.Run(() =&gt; MyLongRunningOperation());

    ResulTextBlock.Text = total.ToString();
}
</code></pre><p>On the above code sample, we wrapped the call to <code>MyLongRunningOperation</code> method with a <code>Task.Run</code> that will force it to execute on a new separate thread, and then awaited for it to complete.</p><p><strong>Note:</strong> Libraries should not lie about what they are doing! The <abbr title="User Interface">UI</abbr> thread is the only one that needs the asynchronous <abbr title="Application Programming Interface">API</abbr>, so it should be up to the end developer to decide when to use this, not 3rd party libraries ones!</p><h2>Avoid using task.Result or task.Wait()</h2><p>If use <code>task.Result</code> or call <code>task.Wait()</code> you will be blocking the current thread until that task completes, which is not ideal especially if the thread is the main <abbr title="User Interface">UI</abbr> thread!</p><p>A particular situation I see people doing this is for constructors; here’s an example:</p><pre><code class="language-csharp">public class TestClass
{
    private int _initialValue;

    public TestClass()
    {
        _initialValue = GetInitialValueTask().Wait(); // don&#x27;t do this!
    }

    public int GetInitialValueDoubled()
    {
        return _initialValue * 2;
    }

    // other code...
}
</code></pre><p>The whole point of the .NET asynchronous model is to use the <code>async</code> and <code>await</code> keywords!</p><p>To avoid this issue, one could write the code like this:</p><pre><code class="language-csharp">public class TestClass
{
    private Task&lt;int&gt; _initialValueTask;

    public TestClass()
    {
        _initialValueTask = GetInitialValueTask(); // store the async task
    }

    public async Task&lt;int&gt; GetInitialValueDoubled()
    {
        var value = await _initialValueTask;

        return value * 2;
    }

    // other code...
}
</code></pre><p>Instead of blocking the thread like we did before, we just store the asynchronous task and when we need it, we ensure we access it from an <code>async</code> method so we can <code>await</code> on it!</p><h2>Use task.ConfigureAwait(false) whenever possible</h2><p>Developers should assume that the <code>await</code> keyword will make any call return to calling thread.</p><p>Consider the following sample code:</p><pre><code class="language-csharp">private async void CalculateButton_OnClick(object sender, RoutedEventArgs e)
{
    await IoBoundOperation();

    await AnotherIoBoundOperation();

    ResultTextBlock.Text = &quot;Done!&quot;;
}
</code></pre><p>Both <code>IoBoundOperation</code> and <code>AnotherIoBoundOperation</code> have <abbr title="Input/Output">IO</abbr> bound code, so they will most likely execute on separate threads.</p><p>Once these awaited calls finish and return, execution might resume on the calling thread, which in this case is the <abbr title="User Interface">UI</abbr> thread.</p><p>However, most likely this isn’t required, and we could just carry on execution on the same background thread.</p><p>Now look at the modified version of the sample code:</p><pre><code class="language-csharp">private async void CalculateButton_OnClick(object sender, RoutedEventArgs e)
{
    await IoBoundOperation()
        .ConfigureAwait(false);

    await AnotherIoBoundOperation()
        .ConfigureAwait(false);

    Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =&gt;
    {
        ResulTextBlock.Text = total.ToString();
    });
}
</code></pre><p>We have now added <code>.ConfigureAwait(false)</code> to each awaited call as to avoid marshaling back to the calling thread.</p><p>Any code that needs to run on the <abbr title="User Interface">UI</abbr> thread (normally, to update the <abbr title="User Interface">UI</abbr>) can do so by using the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.core.coredispatcher#Windows_UI_Core_CoreDispatcher_RunAsync_?wt.mc_id=MVP">Dispatcher.RunAsync</a> method as seen above.</p><h2>Consider using Deferred Events for your custom events</h2><p>The rule of thumb on the asynchronous code is to avoid <code>async void</code> methods as much as possible, but for event handlers, there is no way to bypass this.</p><p>A while back I created the <a href="https://www.nuget.org/packages/DeferredEvents/">DeferredEvents</a> NuGet package to mitigate this issue; at the time, I wrote an <a href="/2017/04/04/await-your-event-handlers-completion-with-deferred-events/">article</a> that I now recommend reading to further understand the problem and my proposed solution.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Developer Day]]></title>
            <link>https://www.pedrolamas.com/2017/10/06/windows-developer-day/</link>
            <guid>https://www.pedrolamas.com/2017/10/06/windows-developer-day/</guid>
            <pubDate>Fri, 06 Oct 2017 10:33:14 GMT</pubDate>
            <content:encoded><![CDATA[<p>On October 10, Microsoft is hosting the <a href="https://blogs.windows.com/buildingapps/2017/09/14/windows-developer-day-returns/">Windows Developer Day</a> here in London, and you can watch the live stream starting at <time dateTime="2017-10-10T16:30:00Z">9:30 AM PDT</time>.</p><p>The event will start with a keynote by Kevin Gallo and members of the Windows engineering team, followed by a live-streamed Q&amp;A session and several streaming sessions diving deeper into what’s new for developers in the Windows 10 Fall Creators Update.</p><p>You might also want to check if there’s a viewing party in your area (check on the bottom of <a href="https://blogs.windows.com/buildingapps/2017/09/14/windows-developer-day-returns/">this post</a>).</p><h2>And if you’re around London on the next day…</h2><p>… come to the next <a href="https://www.meetup.com/wpuguk/">Windows Apps London</a> meetup at <time dateTime="2017-10-11T17:30:00Z">6:30 PM on October 11</time> and meet the Windows engineering team!</p><p>This is a relaxed in-person event, where you’ll get to ask a few more questions after the main Windows Developer Day!</p><p>Please check <a href="https://www.meetup.com/wpuguk/events/243674562/">here</a> for more details and registration.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Xamarin Certified Mobile Developer]]></title>
            <link>https://www.pedrolamas.com/2017/07/24/xamarin-certified-mobile-developer/</link>
            <guid>https://www.pedrolamas.com/2017/07/24/xamarin-certified-mobile-developer/</guid>
            <pubDate>Mon, 24 Jul 2017 11:26:27 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/48db6c7c9f1939d04fde129843af5d34/Xamarin-Certified-Mobile-Developer.png" alt="Xamarin Certified Mobile Developer" class="webfeedsFeaturedVisual" /></p><p>A couple of weeks ago I decided to enroll into <a href="https://university.xamarin.com/">Xamarin University</a> and after a few classes and a final exam, I’m now a <strong>Xamarin Certified Mobile Developer</strong>!</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:68.88888888888889%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAA7DAAAOwwHHb6hkAAADG0lEQVQoz3WO609ScQCGz79TX6pVq6zUWuUldc1mFqWJgIXmtQECUqaQYCpx0RIUYmhSqCgCURjGRS3ykq3pwqUzJ1aoHDhcz4Hza1TWp569H94v794H2pdx7XAu+VAu5WAOKSWfevxixcmCytTCqvQrNacIdWeLaRlERmZpfRaJlU1mZZPZv5NRQj+QWQwdyaOkEWjXbrfS+D0F1fwyTtetJnklT0EXatjSIWan7m6Piasa52tsD7TOjsHJNu1k63OHQGPLobCh1MKqTGLDkNn51fPjNl/xSPNS9tzSM2R9+mJarnOwHuu5KotAY+8Ynhbp5yTmzxLz4sMRl1g/U8IWQ8fyK9KvMoRKnfHN+xt3umpbFExhP0eqbZbpeQpTg8zIVb9u1TpFYwtKo31EyVY/EUuNHyXGD0VMEXSaUHuB2kSoFZQyRUSW+GZjd3WLki4c4HQONytMfPV4u9bROTYjtyyNSMgT3BPOtpOaZ929tjUyRwKpBk0+f3B907vxffvbFvx9G/bu+H/sBLw+ZAtGtv2h7UDYF4zAIdQuJzuF6S7pseV3AwkARL0aSG+xAwBQFMXicRRDsTiGYmgkGonForFYDPwCx3EAAOJ1L47RF8elkUgYACDr10Gjr2wAAB8Mh0LhcCQSiUYxFMVxPIH/BuwWHOwST8QBAN39OkhvcQAAVldX19fXPR7PysqKd2srOd7l7zQexzAshmGxGIr+edaZk88BJOhHEH8g4EcQn9+/A8NwILDjgwPBoGdzc8OzueHxJM2i0VA4jAST2t19w5DJOvnLJAH+A56IAzyRzD/tZJcPjEINbfIx69sRy5RhwmWwul7YZl855y1TCxOuT2/eL9pmlhxz7skPy9Mfvzjm3Y75Zfuc2z77eXZpjdOhgPacKd6bRTl8oTLlUl0agXGuhJNd1pRXfr+gpo1AE11nd5Huyij3FLf4fSrDFLfHwOs1METa8hZ1Zikb2n/u6tF8alphddrlmrNF9Gwi8zyJnV/eVFDJu1LLJ9QJimntxPqHJJaY8UBZfu8RtbGrjNNZwug4kkv8CdItTdQ5N4nZAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Xamarin Certified Mobile Developer certificate" title="Xamarin Certified Mobile Developer certificate" src="/static/a585189214fe8d7178c040376ea329d9/37523/Xamarin-Certified-Mobile-Developer-certificate.png" srcSet="/static/a585189214fe8d7178c040376ea329d9/e9ff0/Xamarin-Certified-Mobile-Developer-certificate.png 180w,/static/a585189214fe8d7178c040376ea329d9/f21e7/Xamarin-Certified-Mobile-Developer-certificate.png 360w,/static/a585189214fe8d7178c040376ea329d9/37523/Xamarin-Certified-Mobile-Developer-certificate.png 720w,/static/a585189214fe8d7178c040376ea329d9/c54b3/Xamarin-Certified-Mobile-Developer-certificate.png 727w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>I love Windows Development and make no mistake: I intend to keep writing and working with full native <abbr title="Universal Windows Platform">UWP</abbr>!!</p><p>But at this time it makes complete sense for someone who works with <abbr title="Extensible Application Markup Language">XAML</abbr> and C# to also learn Xamarin, as this is the best Microsoft has for cross-platform development!</p><p>Xamarin University was a really good experience and I can definitely recommend it to everyone: people that just started coding with .NET and C#, experienced developers who want to learn Xamarin, or professional developers that just want to get Xamarin certified!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Phone is (officially) dead!]]></title>
            <link>https://www.pedrolamas.com/2017/07/10/windows-phone-is-officially-dead/</link>
            <guid>https://www.pedrolamas.com/2017/07/10/windows-phone-is-officially-dead/</guid>
            <pubDate>Mon, 10 Jul 2017 14:34:00 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/ede41d7a159db3f8128ad2f5fc16da0c/Windows-Phone-is-officially-dead.jpg" alt="Windows Phone is (officially) dead!" class="webfeedsFeaturedVisual" /></p><p>Over the last few <del>months</del> years <a href="https://www.forbes.com/sites/curtissilver/2017/05/01/microsoft-windows-phone-is-dead-long-live-the-surface-phone/">quite</a> <a href="https://www.theverge.com/2016/1/28/10864034/windows-phone-is-dead">a few</a> <a href="http://uk.businessinsider.com/microsoft-windows-phone-dead-2016-11">people</a> have written about the Windows Phone demise.</p><p>However, according to <a href="https://support.microsoft.com/en-gb/lifecycle/search?alpha=windows%20phone">Microsoft’s Support Page for product life cycle</a>, the “Mainstream Support End Date” for Windows Phone 8.1 is July 11, 2017… so that’s basically, <em>tomorrow!</em></p><p>Microsoft’s last update for the <abbr title="Windows Phone 8">WP8</abbr>.x operating system (dubbed “Update 2”) was more than 2 years ago… so even if the “official” support only now ended, I think we can all agree that unofficially Microsoft abandoned the OS a long time ago (mostly when they replaced it with Windows 10 Mobile).</p><h2>My own experience with Windows Phone</h2><p>Microsoft announced Windows Phone 7 at the Mobile World Congress in Barcelona, Spain, on February 15, 2010; I remember that the more I saw those screens and learned about the promised capabilities and technical details, the more I knew that I wanted to build apps for it, both as a hobby and professionally - and do so I did!!</p><p>When they released the first Windows Phone devices on October 21, 2010 in Europe, I went straight to a local shop and bought my very first Windows Phone: the magnificent Samsung Omnia 7.</p><p>Soon after that, Microsoft and Nokia got into a partnership to boost the operating system footprint, and as a consequence I ended up leaving Portugal and moving to Bristol <abbr title="United Kingdom">UK</abbr> to join the Nokia Music division, later known as MixRadio!</p><p>Nokia’s first Windows Phone was the Lumia 800, one of the best phones I have ever owned (I actually kept one of these as a souvenir)</p><p>By my account, throughout the years I owed and used at least 12 different Windows Phone devices, mostly due to my time as Nokia employee.</p><p>I also got to do a lot tech-talks on Windows Phone development, and participated in a few hackathons, helping the young and brightest with their projects.</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:66.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAwACBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAF14jxqWX//xAAaEAADAQADAAAAAAAAAAAAAAABAgMAERMU/9oACAEBAAEFApTUpVAJleN6KJp3ex6d/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGhAAAwADAQAAAAAAAAAAAAAAAAEhAhESMv/aAAgBAQAGPwJQcKaThxm4emf/xAAbEAADAAMBAQAAAAAAAAAAAAAAAREhMUFhcf/aAAgBAQABPyF0tW/SVItFMi+F0yTWBkQpcRh2+o//2gAMAwEAAgADAAAAEDzf/8QAFhEBAQEAAAAAAAAAAAAAAAAAABFB/9oACAEDAQE/ENV//8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oACAECAQE/EGV//8QAGhABAAMBAQEAAAAAAAAAAAAAAQARITFBcf/aAAgBAQABPxBq/NdXsT6/oK9JUJYXrJY8cm0YwuuDiS6T7CWf/9k=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Windows Phone 7 development with Silverlight - Microsoft Techdays Portugal 2010" title="Windows Phone 7 development with Silverlight - Microsoft Techdays Portugal 2010" src="/static/a7d7d49acb97dc9bfd1abdc8988032a7/80e3c/Windows-Phone-7-Development-Techdays-Portugal-2010.jpg" srcSet="/static/a7d7d49acb97dc9bfd1abdc8988032a7/4ec73/Windows-Phone-7-Development-Techdays-Portugal-2010.jpg 180w,/static/a7d7d49acb97dc9bfd1abdc8988032a7/158ba/Windows-Phone-7-Development-Techdays-Portugal-2010.jpg 360w,/static/a7d7d49acb97dc9bfd1abdc8988032a7/80e3c/Windows-Phone-7-Development-Techdays-Portugal-2010.jpg 720w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><h2>“The King is dead, long live the King!”</h2><p>Microsoft arrived late to the “mobile party” and made lots of mistakes (the lack of software upgrades for “older” devices, some less than a year old, being the biggest), but it was the lack of true first-party apps that caused users to lose interest in the phones and doomed the mobile operating system.</p><p>Windows 10 makes good on the promise of “one Windows for all devices”, but the mobile flavor never did get the same praise as the Windows Phone did - and I strongly agree with that!</p><p>I enjoyed all my Windows Phone devices, and I will miss using them a lot… but life goes on!</p><p>Farewell, Windows Phone.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit 2.5.0]]></title>
            <link>https://www.pedrolamas.com/2017/05/11/cimbalino-toolkit-2-5-0/</link>
            <guid>https://www.pedrolamas.com/2017/05/11/cimbalino-toolkit-2-5-0/</guid>
            <pubDate>Thu, 11 May 2017 11:00:40 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit 2.5.0" class="webfeedsFeaturedVisual" /></p><p>Yesterday I released <a href="http://cimbalino.org/"><strong>Cimbalino Toolkit</strong></a> version 2.5.0!</p><p>Here’s what’s changed on this version:</p><ul><li>Cimbalino.Toolkit.Core now targets the .NET Standard 1.0</li><li>Cimbalino.Toolkit.Core will now behave as the rest of the toolkit in regards to throwing <code>NotImplementedExceptions</code> only on specific cases</li><li>Exposed overrideable async methods in <code>ExtendedPageBase</code></li><li>Other fixes and improvements</li></ul><p>From the above, I’d like to emphasise the huge advantage of supporting .NET Standard 1.0: this means <strong>you can now use Cimbalino.Tookit.Core in all .NET platforms: .NET Framework, .NET Core, and Mono!</strong></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CultureInfo changes in UWP - Part 2]]></title>
            <link>https://www.pedrolamas.com/2017/05/03/cultureinfo-changes-in-uwp-part-2/</link>
            <guid>https://www.pedrolamas.com/2017/05/03/cultureinfo-changes-in-uwp-part-2/</guid>
            <pubDate>Wed, 03 May 2017 13:26:33 GMT</pubDate>
            <content:encoded><![CDATA[<p>A while back I wrote an article about the <a href="/2015/11/02/cultureinfo-changes-in-uwp/">CultureInfo changes in <abbr title="Universal Windows Platform">UWP</abbr></a> and how they affected the <abbr title="Universal Windows Platform">UWP</abbr> apps.</p><p>Well, things haven’t changed much since then, and the information in that article still stands today!</p><p>However, Microsoft has since open-sourced the <a href="https://github.com/dotnet/corert">.NET Core Runtime (CoreRT)</a>, and that allowed me to take a peek under the hood to understand what is going on.</p><p>While looking at the <a href="https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs#L399">CultureInfo.cs</a> code, I noticed the following comment on the <code>CurrentCulture</code> property:</p><blockquote><p>We use the following order to return CurrentCulture and CurrentUICulture</p><ul><li>Use WinRT to return the current user profile language</li><li>Use current thread culture if the user already set one using CurrentCulture/CurrentUICulture</li><li>Use thread culture if the user already set one using DefaultThreadCurrentCulture or DefaultThreadCurrentUICulture</li><li>Use NLS default user culture</li><li>Use NLS default system culture</li><li>Use Invariant culture</li></ul></blockquote><p>This confirms our findings!</p><p>Looking on the <a href="https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs">CultureInfo.Windows.cs</a> partial class, I noticed the <code>#if ENABLE_WINRT</code> on the top, which forces the first rule on that comment!</p><p>Further down in the same file, we find a <code>GetUserDefaultCulture</code> method which uses the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd318103.aspx">GetLocaleInfoEx</a> Win32 <abbr title="Application Programming Interface">API</abbr> to retrieve the locale name.</p><p>This Win32 <abbr title="Application Programming Interface">API</abbr> is actually <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt644399.aspx#_api-ms-win-core-localization-l1-2-1.dll">allowed for apps published to the Windows Store</a>!</p><h2>Retrieving the “proper” CurrentCulture, the proper way!</h2><p>In my <a href="/2015/11/02/cultureinfo-changes-in-uwp/">previous article</a> on this subject, I found a hack where one could retrieve the “proper” CurrentCulture using the <code>DateTimeFormatter</code> class.</p><p>But with all this new information, I have now created a non-hacky way of doing the same:</p><pre><code class="language-csharp">using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;

public class CultureInfoHelper
{
    [DllImport(&quot;api-ms-win-core-localization-l1-2-0.dll&quot;, CharSet = CharSet.Unicode)]
    private static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, StringBuilder lpLCData, int cchData);

    private const uint LOCALE_SNAME = 0x0000005c;
    private const string LOCALE_NAME_USER_DEFAULT = null;
    private const string LOCALE_NAME_SYSTEM_DEFAULT = &quot;!x-sys-default-locale&quot;;

    private const int BUFFER_SIZE = 530;

    public static CultureInfo GetCurrentCulture()
    {
        var name = InvokeGetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME);

        if (name == null)
        {
            name = InvokeGetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME);

            if (name == null)
            {
                // If system default doesn&#x27;t work, use invariant
                return CultureInfo.InvariantCulture;
            }
        }

        return new CultureInfo(name);
    }

    private static string InvokeGetLocaleInfoEx(string lpLocaleName, uint LCType)
    {
        var buffer = new StringBuilder(BUFFER_SIZE);

        var resultCode = GetLocaleInfoEx(lpLocaleName, LCType, buffer, BUFFER_SIZE);

        if (resultCode &gt; 0)
        {
            return buffer.ToString();
        }

        return null;
    }
}
</code></pre><p>All you need is to copy the above to a file in your <abbr title="Universal Windows Platform">UWP</abbr> project, and then call <code>CultureInfoHelper.GetCurrentCulture()</code>.</p><p>I strongly advise using this new method instead of the “hack” I used in my previous article, as this is the same one that the .NET Framework relies on to retrieve the CurrentCulture information!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating custom build configurations for the .NET Core project format]]></title>
            <link>https://www.pedrolamas.com/2017/04/24/creating-custom-build-configurations-for-the-dotnet-core-project-format/</link>
            <guid>https://www.pedrolamas.com/2017/04/24/creating-custom-build-configurations-for-the-dotnet-core-project-format/</guid>
            <pubDate>Mon, 24 Apr 2017 13:58:05 GMT</pubDate>
            <content:encoded><![CDATA[<p>MSBuild based projects have two default build configurations: Debug and Release.</p><p>While these two configurations are enough for most projects, some might actually require custom build configurations that will support different environments, alternative build targets, etc..</p><p>Until now we could use Visual Studio Configuration Manager to easily create a copy an existing configuration setup, and then change small bits to match our specifications.</p><p>But now there’s a <a href="https://docs.microsoft.com/en-us/dotnet/articles/core/tools/csproj?wt.mc_id=MVP">new csproj format for .NET Core</a>, and while it includes the expected Debug and Release build configurations, the “copy configuration” process doesn’t work anymore!</p><p>The problem is that the new project format is based in quite a few implicit defaults, so Visual Studio Configuration Manager can’t actually create a copy of the existing build configurations with all the properties set.</p><h2>Introducing the MSBuild Configuration Defaults</h2><p>As I couldn’t find a way to “inherit” from the base Debug and Release build configurations, I tried to understand what properties were actually required on each of them, and then create some build scripts that would set them for me!</p><p>Those MSBuild scripts are available <a href="https://github.com/pedrolamas/MSBuildConfigurationDefaults">here</a> and can easily be installed by running <code>Install-Package MSBuildConfigurationDefaults</code> on the Package Manager Console, or added with the Visual Studio NuGet Packages Manager.</p><p>After adding the NuGet package, I recommend closing and re-opening the solution to ensure that the build scripts are correctly loaded.</p><h2>Usage</h2><p>Once installed, any custom build configuration name starting or ending on “Debug” will have the following build properties set by default:</p><pre><code class="language-xml">&lt;DefineConstants&gt;$(DefineConstants);DEBUG;TRACE&lt;/DefineConstants&gt;
&lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
&lt;DebugType&gt;full&lt;/DebugType&gt;
&lt;Optimize&gt;false&lt;/Optimize&gt;
</code></pre><p>Similarly, any custom build configuration name starting or ending on “Release” will have the following build properties set by default:</p><pre><code class="language-xml">&lt;DefineConstants&gt;$(DefineConstants);RELEASE;TRACE&lt;/DefineConstants&gt;
&lt;DebugSymbols&gt;false&lt;/DebugSymbols&gt;
&lt;DebugType&gt;portable&lt;/DebugType&gt;
&lt;Optimize&gt;true&lt;/Optimize&gt;
</code></pre><p>If any of these properties are set on the project, those values will have override the defaults above.</p><p>If you don’t want to name your custom build definition according to the rules above, just add a <code>ConfigurationGroup</code> property and set the value to <code>Debug</code> or <code>Release</code> to ensure those build definitions get the appropriate default properties set.</p><p>The following is an example of a custom build configuration called “Production”, that has the <code>ConfigurationGroup</code> set to “Release” (so it gets the default property values set as for the a “Release” build configuration), but also overrides the <code>DebugSymbols</code> property default value:</p><pre><code class="language-xml">&lt;PropertyGroup Condition=&quot;&#x27;$(Configuration)&#x27; == &#x27;Production&#x27;&quot;&gt;
  &lt;ConfigurationGroup&gt;Release&lt;/ConfigurationGroup&gt;
  &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
&lt;/PropertyGroup&gt;
</code></pre>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Await your event handlers completion with Deferred Events]]></title>
            <link>https://www.pedrolamas.com/2017/04/04/await-your-event-handlers-completion-with-deferred-events/</link>
            <guid>https://www.pedrolamas.com/2017/04/04/await-your-event-handlers-completion-with-deferred-events/</guid>
            <pubDate>Tue, 04 Apr 2017 13:55:59 GMT</pubDate>
            <content:encoded><![CDATA[<p><strong>Deprecation notice:</strong> The DeferredEvents are now part of the <a href="https://www.nuget.org/packages/Microsoft.Toolkit">Microsoft.Toolkit</a> where it will be maintained from this point on.</p><hr/><p>Developers should avoid <code>async void</code> methods, but there are some situations where this is a “necessary evil”, and event handlers are one of those cases.</p><p>If one needs to use the <code>await</code> keyword inside an event handler code, the method itself must be <code>async void</code></p><p>The following is an example of this:</p><pre><code class="language-csharp">public sealed partial class MainPage : Page
{
    public MainPage()
    {
        InitializeComponent();

        Loaded += MainPage_Loaded;
    }

    private async void MainPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    {
        await DoSomethingAsync();

        await DoSomethingMoreAsync();
    }
}
</code></pre><p>On the above example, the <code>MainPage_Loaded</code> is an <code>async void</code> method that will as it needs to await for the completion of some of its calls, but sometimes we also need to allow the event invoker to wait for all handlers to complete.</p><p>Inspired on how the background tasks use a deferral approach to solving this problem (as they too are <code>void</code> methods), I came up with a similar approach!</p><h2>Introducing the Deferred Events</h2><p>A “deferred event” is basically an event that allows the invoker to wait for the completion of all event handlers.</p><p>My personal implementation is available on the <a href="https://www.nuget.org/packages/DeferredEvents/">DeferredEvents NuGet package</a> that you can install by running <code>Install-Package DeferredEvents</code> on the <a href="https://docs.nuget.org/docs/start-here/using-the-package-manager-console">Package Manager Console</a>, or add with Visual Studio NuGet Packages Manager.</p><p>This is a .NET Standard 1.0 package, so you should be able to use it on any .NET project!</p><p>If you want to take a look at what’s inside, the full source code is available <a href="https://github.com/pedrolamas/DeferredEvents">here</a>.</p><h2>Usage</h2><p>Here is an example of a deferred event:</p><pre><code class="language-csharp">public event EventHandler&lt;DeferredEventArgs&gt; MyEvent;
</code></pre><p>The only difference here to a regular event is that the event arguments have to be of type <a href="https://github.com/pedrolamas/DeferredEvents/blob/master/DeferredEvents/DeferredEventArgs.cs">DeferredEventArgs</a> (or a custom class inheriting from them), and that’s what allows the whole thing to work!</p><p>Now take a look at how we raise this event:</p><pre><code class="language-csharp">await MyEvent.InvokeAsync(sender, new DeferredEventArgs());
</code></pre><p>The <code>InvokeAsync()</code> is an extension method that will wait for all event handlers to finish their work before we proceed.</p><p>And finally, here’s how our event handler looks like:</p><pre><code class="language-csharp">public async void OnMyEvent(object sender, DeferredEventArgs e)
{
    var deferral = e.GetDeferral();

    await DoSomethingAsync();

    deferral.Complete();
}
</code></pre><p>The trick here is to call <code>e.GetDeferral()</code> to retrieve a deferral object, and just before we exit the method, we do <code>deferral.Complete()</code> to notify the invoker that we have completed our work!</p><p>There are a few rules that you have to be aware of:</p><ul><li>You only need to call <code>e.GetDeferral()</code> if you actually want to the event caller to wait for the completion of the event handler; if you don’t call it, it will just behave as a regular event handler.</li><li>You <strong>must</strong> call <code>e.GetDeferral()</code> to get an <code>EventDeferral</code> instance before any <code>await</code> call in your code to ensure that the event caller knows that it should wait for <code>deferral.Complete()</code>; ideally, it should be the first thing you do in the event handler code.</li><li>If you have indeed called <code>e.GetDeferral()</code>, then you <strong>must</strong> call <code>deferral.Complete()</code> to signal that the event handler has finished.</li></ul><p>To ensure the correct usage of the deferred events, use the following as a template for your event handlers:</p><pre><code class="language-csharp">public async void OnMyEvent(object sender, DeferredEventArgs e)
{
    var deferral = e.GetDeferral();

    try
    {
        // awaiteable code
    }
    finally
    {
        deferral.Complete();
    }
}
</code></pre><p>Alternatively, you can also use the <code>using</code> pattern like this:</p><pre><code class="language-csharp">public async void OnMyEvent(object sender, DeferredEventArgs e)
{
    using (e.GetDeferral())
    {
        // awaiteable code
    }
}
</code></pre>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting a custom User-Agent in the UWP WebView control]]></title>
            <link>https://www.pedrolamas.com/2017/03/21/setting-a-custom-user-agent-in-the-uwp-webview-control/</link>
            <guid>https://www.pedrolamas.com/2017/03/21/setting-a-custom-user-agent-in-the-uwp-webview-control/</guid>
            <pubDate>Tue, 21 Mar 2017 12:10:45 GMT</pubDate>
            <content:encoded><![CDATA[<p>I recently came into a <abbr title="Universal Windows Platform">UWP</abbr> project requiring all <abbr title="Hypertext Transfer Protocol">HTTP</abbr> requests to use a specific User-Agent string.</p><p>That’s quite easy to do if you only use <a href="https://docs.microsoft.com/en-us/uwp/api/windows.web.http.httpclient?wt.mc_id=MVP">Windows.Web.Http.HttpClient</a> as there’s a managed property for that purpose: <a href="https://docs.microsoft.com/en-us/uwp/api/windows.web.http.headers.httprequestheadercollection#Windows_Web_Http_Headers_HttpRequestHeaderCollection_UserAgent?wt.mc_id=MVP">HttpClient.DefaultRequestHeaders.UserAgent</a>.</p><p>Similarly, the same applies for <a href="https://docs.microsoft.com/en-us/dotnet/core/api/system.net.http.httpclient?wt.mc_id=MVP">System.Net.Http.HttpClient</a> and the <a href="https://docs.microsoft.com/en-us/dotnet/core/api/system.net.http.headers.httprequestheaders#System_Net_Http_Headers_HttpRequestHeaders_UserAgent?wt.mc_id=MVP">HttpClient.DefaultHeader.UserAgent</a> property.</p><p>The real problem is if you need to use the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview?wt.mc_id=MVP">WebView</a> control to present web content, as there’s no managed property to change the user-agent!</p><p>It is possible to create a <a href="https://docs.microsoft.com/en-us/uwp/api/windows.web.http.httprequestmessage?wt.mc_id=MVP">HttpRequestMessage</a> instance, set a custom user-agent string in it, and then call the <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview#Windows_UI_Xaml_Controls_WebView_NavigateWithHttpRequestMessage_Windows_Web_Http_HttpRequestMessage_?wt.mc_id=MVP">WebView.NavigateWithHttpRequestMessage</a> method, but that will only work for that specific navigation request.</p><p>Any requests invoked from inside the webview (like a form post) will use the system default user-agent string.</p><h2>So what’s the solution?</h2><p>The solution comes in the form of a Win32 <abbr title="Application Programming Interface">API</abbr> called <a href="https://msdn.microsoft.com/en-us/library/ms775125(v=vs.85).aspx">UrlMkSetSessionOption</a>.</p><p>Amongst other things, this <abbr title="Application Programming Interface">API</abbr> allows you to set the default user-agent string for the current internet session!</p><p>Here’s an example of how to use it; first, add the following class to your app:</p><pre><code class="language-csharp">public class UserAgentHelper
{
    [DllImport(&quot;urlmon.dll&quot;, CharSet = CharSet.Ansi, ExactSpelling = true)]
    private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);

    private const int URLMON_OPTION_USERAGENT = 0x10000001;

    public static void SetDefaultUserAgent(string userAgent)
    {
        UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, userAgent, userAgent.Length, 0);
    }
}
</code></pre><p>Now load your App.xaml.cs file and ensure you call the <code>UserAgentHelper.SetDefaultUserAgent()</code> method inside the <code>App</code> class constructor:</p><pre><code class="language-csharp">public App()
{
    // remaining code

    UserAgentHelper.SetDefaultUserAgent(&quot;MyApp/1.0&quot;);
}
</code></pre><p>From that point on, any webview inside your app will use the specified user-agent string (“MyApp/1.0” in our example above)!</p><p>One final note: only a few Win32 <abbr title="Application Programming Interface">API</abbr>’s are actually allowed in apps published to the Windows Store (you can check the complete list <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt644399.aspx">here</a>)!</p><p>The Windows Store recently allowed for apps to use the <code>UrlMkSetSessionOption</code> <abbr title="Application Programming Interface">API</abbr>, but if you look at the list above you will notice that it’s <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt644399.aspx#_urlmon.dll">not yet listed</a>; that should change once Microsoft updates the list on that page.</p><p>Kudos to <a href="https://twitter.com/hermitdave">Hermit Dave</a> for pointing me in the right direction for a solution for this problem!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrated from WordPress to Jekyll]]></title>
            <link>https://www.pedrolamas.com/2017/03/13/migrated-from-wordpress-to-jekyll/</link>
            <guid>https://www.pedrolamas.com/2017/03/13/migrated-from-wordpress-to-jekyll/</guid>
            <pubDate>Mon, 13 Mar 2017 09:02:01 GMT</pubDate>
            <content:encoded><![CDATA[<p>For a long time now, my blog has been powered by <a href="http://wordpress.org">WordPress</a> and hosted on <a href="http://www.godaddy.com">GoDaddy</a> shared hosting.</p><p>Last week I noticed that the blog was down, and when I opened GoDaddy’s shared hosting administration area, I got a database connection error message.</p><p>I then did what anyone in this situation would do: get help!</p><p>However, contacting GoDaddy support proved completely useless, as all I got was something along the lines of <em>“yes, there’s a problem and we’re working on to fix it; no, we don’t know when it’s gonna be fixed, so please try later”</em>…</p><blockquote class="twitter-tweet" data-conversation="none" data-lang="en"><p lang="en" dir="ltr">Just had a chat with <a href="https://twitter.com/GoDaddy">@GoDaddy</a> support, their server is down and all I got was &quot;we know it&#x27;s down, just try later...&quot; <a href="https://twitter.com/hashtag/fail?src=hash">#fail</a> <a href="https://twitter.com/GoDaddyHelp">@GoDaddyHelp</a></p>— Pedro Lamas (@pedrolamas) <a href="https://twitter.com/pedrolamas/status/839089470880247813">March 7, 2017</a></blockquote><script async="" src="//platform.twitter.com/widgets.js" charSet="utf-8"></script><p>After some 5 hours, the blog was back up and running… but there was a big problem: <strong>some content had disappeared!</strong></p><p>I’m guessing they had some problem with the database server, and their “fix” involved recovering the databases from an old backup.</p><blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Seems <a href="https://twitter.com/GoDaddy">@GoDaddy</a> hosting admins &quot;fix&quot; was to RECOVER AN OLD DATABASE BACKUP, so all my latest changes have been lost... <a href="https://twitter.com/GoDaddyHelp">@GoDaddyHelp</a> <a href="https://t.co/ROROWqxfQP">https://t.co/ROROWqxfQP</a></p>— Pedro Lamas (@pedrolamas) <a href="https://twitter.com/pedrolamas/status/840237008551333888">March 10, 2017</a></blockquote><script async="" src="//platform.twitter.com/widgets.js" charSet="utf-8"></script><p>That was the final reason I needed to completely ditch WordPress and GoDaddy, and migrate to something faster and more recent: this blog is now fully powered by <a href="https://jekyllrb.com">Jekyll</a> and hosted in <a href="https://pages.github.com">GitHub Pages</a>!</p><p>Major advantages of this approach are:</p><ul><li>No more MySQL or any other database server involved</li><li>full control over rendered content</li><li>everything is statically generated on every commit of the git repo, so <strong>it’s blazing fast!</strong></li><li>I can <strong>host it for free in GitHub Pages</strong> and add some nice features like allowing other people to send me Pull Requests with fixes and improvements (or just to correct my recurrent typos!)</li></ul><p>This right now is actually the first post I write in the new platform! :)</p><p>There are still a few quirks to fix, so if you find any problem please report it by <a href="https://github.com/pedrolamas/pedrolamas.com/issues/new">creating a new issue</a> and I’ll take care of it as soon as possible!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Awarded Microsoft Windows Development MVP 2017]]></title>
            <link>https://www.pedrolamas.com/2017/03/02/awarded-microsoft-windows-development-mvp-2017/</link>
            <guid>https://www.pedrolamas.com/2017/03/02/awarded-microsoft-windows-development-mvp-2017/</guid>
            <pubDate>Thu, 02 Mar 2017 10:17:20 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/e779ddbc9d7b740c9e826bb0bcd10cef/MVP_Logo_Horizontal_Preferred_Cyan300_RGB_300ppi.png" alt="Awarded Microsoft Windows Development MVP 2017" class="webfeedsFeaturedVisual" /></p><p>It is with great pride that I received the <strong>Microsoft Most Valuable Professional (<abbr title="Most Valuable Professional">MVP</abbr>) Award 2017 for Windows Development</strong>!</p><p>From the <a href="https://mvp.microsoft.com/en-us/overview">Microsoft <abbr title="Most Valuable Professional">MVP</abbr> award overview page</a>:</p><blockquote><p>“…the Microsoft <abbr title="Most Valuable Professional">MVP</abbr> Award is our way of saying “Thanks!” to outstanding community leaders.”</p></blockquote><p>This is my first <abbr title="Most Valuable Professional">MVP</abbr> Awards and to me feels like the top recognition for all the work I’ve been doing for the past few years with the community around Microsoft Technologies, particularly in Windows and Windows Phone development.</p><p>I consider this award as a personal achievement, but it is one that I could not have accomplished without the help and support of some people, specifically:</p><ul><li><strong>Scott Lovegrove</strong>, <strong>Joost van Schaik</strong>, <strong>Glenn Versweyveld</strong>, <strong>Hermit Dave</strong>, <strong>Sébastien Lachance</strong>, <strong>Bart Lannoeye</strong>, and quite a few other distinguished <abbr title="Most Valuable Professional">MVP</abbr>’s!</li><li><strong>Alberto Silva</strong>, <strong>Sandro Pereira</strong>, <strong>Tiago Pascoal</strong>, <strong>Paulo Morgado</strong>, and other fellow Portuguese <abbr title="Most Valuable Professional">MVP</abbr>’s!</li><li><strong>Luis Calado</strong>, <strong>João Pedro Martins</strong>, <strong>Clint Rutkas</strong>, and quite a few other Microsoft employees!</li><li>my wife, <strong>Joana</strong>, who has the patience to put up with me doing “geeky” stuff all the time!</li></ul><p>…and finally but most importantly, <strong>the whole community</strong>, who reads my blog, follows me on twitter, checks my code contributions, downloads my apps, and gives me the opportunity to carry on doing what I’ve done so far and that will continue to improve in the future!</p><p>Thanks! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adaptive Triggers failing? Better check your control names!]]></title>
            <link>https://www.pedrolamas.com/2016/12/09/adaptive-triggers-failing-better-check-your-control-names/</link>
            <guid>https://www.pedrolamas.com/2016/12/09/adaptive-triggers-failing-better-check-your-control-names/</guid>
            <pubDate>Fri, 09 Dec 2016 12:06:06 GMT</pubDate>
            <content:encoded><![CDATA[<h2><abbr title="Too Long">TL</abbr>;<abbr title="Didn&#x27;t Read">DR</abbr></h2><p>Adaptive triggers will not work if you are trying to change a control whose instance name is the same as one of the VisualStates of <strong>any</strong> control on the page, so make sure you name your controls accordingly!</p><h2>The long run…</h2><p>I recently came to discover what I believe to be a <abbr title="Universal Windows Platform">UWP</abbr> platform bug related to how one names the instance controls and how these may collided with the VisualState names!</p><p>Let’s take the following sample code for a simple <a href="https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.adaptivetrigger.aspx">AdaptiveTrigger</a> usage example:</p><pre><code class="language-xml">&lt;Grid Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
    &lt;Button x:Name=&quot;MyButton&quot; Content=&quot;I don&#x27;t do anything!&quot; /&gt;

    &lt;VisualStateManager.VisualStateGroups&gt;
        &lt;VisualStateGroup x:Name=&quot;VisualStateGroup&quot;&gt;
            &lt;VisualState x:Name=&quot;VisualStateNarrow&quot;&gt;
                &lt;VisualState.StateTriggers&gt;
                    &lt;AdaptiveTrigger MinWindowWidth=&quot;0&quot; /&gt;
                &lt;/VisualState.StateTriggers&gt;
                &lt;VisualState.Setters&gt;
                    &lt;Setter Target=&quot;MyButton.Background&quot; Value=&quot;Red&quot; /&gt;
                &lt;/VisualState.Setters&gt;
            &lt;/VisualState&gt;

            &lt;VisualState x:Name=&quot;VisualStateNormal&quot;&gt;
                &lt;VisualState.StateTriggers&gt;
                    &lt;AdaptiveTrigger MinWindowWidth=&quot;600&quot; /&gt;
                &lt;/VisualState.StateTriggers&gt;
                &lt;VisualState.Setters&gt;
                    &lt;Setter Target=&quot;MyButton.Background&quot; Value=&quot;Green&quot; /&gt;
                &lt;/VisualState.Setters&gt;
            &lt;/VisualState&gt;
        &lt;/VisualStateGroup&gt;
    &lt;/VisualStateManager.VisualStateGroups&gt;
&lt;/Grid&gt;
</code></pre><p>Here we can see we have a <code>Button</code> called “MyButton”, who’s background color will change accordingly to the window size: if the window width is above 600, the button will be green, and if it is below 600, it will be red.</p><p>Now here’s how it looks when we run the sample code:</p><p><img src="/1daeed666f6ebf60a47558cc334250c9/Simple-AdaptiveTrigger-working.gif" alt="Simple AdaptiveTrigger working"/></p><p>Works exactly as expected! :)</p><p>If you take a look at the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt299109.aspx">Button styles and templates</a>, you will find out that the <code>Button</code> control contains the following named VisualStates: “Normal”, “PointerOver”, “Pressed”, “Disabled”.</p><p>Given this information, let’s rename our button from “MyButton” to “Pressed”:</p><pre><code class="language-xml">&lt;Grid Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
    &lt;Button x:Name=&quot;Pressed&quot; Content=&quot;I don&#x27;t do anything!&quot; /&gt;

    &lt;VisualStateManager.VisualStateGroups&gt;
        &lt;VisualStateGroup x:Name=&quot;VisualStateGroup&quot;&gt;
            &lt;VisualState x:Name=&quot;VisualStateNarrow&quot;&gt;
                &lt;VisualState.StateTriggers&gt;
                    &lt;AdaptiveTrigger MinWindowWidth=&quot;0&quot; /&gt;
                &lt;/VisualState.StateTriggers&gt;
                &lt;VisualState.Setters&gt;
                    &lt;Setter Target=&quot;Pressed.Background&quot; Value=&quot;Red&quot; /&gt;
                &lt;/VisualState.Setters&gt;
            &lt;/VisualState&gt;

            &lt;VisualState x:Name=&quot;VisualStateNormal&quot;&gt;
                &lt;VisualState.StateTriggers&gt;
                    &lt;AdaptiveTrigger MinWindowWidth=&quot;600&quot; /&gt;
                &lt;/VisualState.StateTriggers&gt;
                &lt;VisualState.Setters&gt;
                    &lt;Setter Target=&quot;Pressed.Background&quot; Value=&quot;Green&quot; /&gt;
                &lt;/VisualState.Setters&gt;
            &lt;/VisualState&gt;
        &lt;/VisualStateGroup&gt;
    &lt;/VisualStateManager.VisualStateGroups&gt;
&lt;/Grid&gt;
</code></pre><p>This is the result if you run the code again:</p><p><img src="/294223fd5bcde0026467ec459f50ada3/AdaptiveTrigger-now-failing.gif" alt="AdaptiveTrigger now failing"/></p><p>What you see here is that the initial state was in fact applied, but it failed to change once we started to change the window size as it was supposed to!</p><p>Further testing made me aware that this is not only influenced by the visual states of the control we are manipulating, but by <strong>all</strong> controls on the page!</p><p>As an example of this, on the following code we have now added a <code>ComboBox</code> control, which will also fail the adaptive changes as I named our button <code>Focused</code> which matches one of the <code>ComboBox</code> visual states:</p><pre><code class="language-xml">&lt;Grid Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
    &lt;Button x:Name=&quot;Focused&quot; Content=&quot;I don&#x27;t do anything!&quot; /&gt;
    &lt;ComboBox /&gt;

    &lt;VisualStateManager.VisualStateGroups&gt;
        &lt;VisualStateGroup x:Name=&quot;VisualStateGroup&quot;&gt;
            &lt;VisualState x:Name=&quot;VisualStateNarrow&quot;&gt;
                &lt;VisualState.StateTriggers&gt;
                    &lt;AdaptiveTrigger MinWindowWidth=&quot;0&quot; /&gt;
                &lt;/VisualState.StateTriggers&gt;
                &lt;VisualState.Setters&gt;
                    &lt;Setter Target=&quot;Focused.Background&quot; Value=&quot;Red&quot; /&gt;
                &lt;/VisualState.Setters&gt;
            &lt;/VisualState&gt;

            &lt;VisualState x:Name=&quot;VisualStateNormal&quot;&gt;
                &lt;VisualState.StateTriggers&gt;
                    &lt;AdaptiveTrigger MinWindowWidth=&quot;600&quot; /&gt;
                &lt;/VisualState.StateTriggers&gt;
                &lt;VisualState.Setters&gt;
                    &lt;Setter Target=&quot;Focused.Background&quot; Value=&quot;Green&quot; /&gt;
                &lt;/VisualState.Setters&gt;
            &lt;/VisualState&gt;
        &lt;/VisualStateGroup&gt;
    &lt;/VisualStateManager.VisualStateGroups&gt;
&lt;/Grid&gt;
</code></pre><p>I’ve reported this issue to Microsoft, so for now all we can do is to be aware of it and make sure we name our controls so not to use the same names as any of their visual states!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit 2.4.0]]></title>
            <link>https://www.pedrolamas.com/2016/12/06/cimbalino-toolkit-2-4-0/</link>
            <guid>https://www.pedrolamas.com/2016/12/06/cimbalino-toolkit-2-4-0/</guid>
            <pubDate>Tue, 06 Dec 2016 12:17:02 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit 2.4.0" class="webfeedsFeaturedVisual" /></p><p>I know the blog as been quite a bit quiet for the last couple of months, but I just wanted to let you know that <a href="http://cimbalino.org/"><strong>Cimbalino Toolkit</strong></a> version 2.4.0 is now available!</p><p>As I didn’t put a blog post for the previous version, here’s the complete change log for everything since 2.2.0 till the current 2.4.0:</p><ul><li>Now targeting <abbr title="Software Development Kit">SDK</abbr> 14393 (Windows 10 Anniversary edition)</li><li>New <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit.Controls%20(UWP)/Controls/MasterDetailView.cs">MasterDetailView</a> control (<abbr title="Universal Windows Platform">UWP</abbr> only)</li><li>New <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit%20(WP8)/Controls/ExtendedPageBase.cs">ExtendedPageBase</a> class, <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit.Core%20(Portable)/Handlers/IHandleNavigatingFrom.cs">IHandleNavigatingFrom</a>, <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit.Core%20(Portable)/Handlers/IHandleNavigatedFrom.cs">IHandleNavigatedFrom</a> and <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit.Core%20(Portable)/Handlers/IHandleNavigatedTo.cs">IHandleNavigatedTo</a> interfaces (allows handling of <code>Page.OnNavigatingFrom()</code>, <code>Page.OnNavigatedFrom()</code> and <code>Page.OnNavigatedTo()</code> methods from inside view models)</li><li>New <code>BooleanToObjectConverter</code>, <code>CollectionCountToObjectConverter</code>, <code>ComparableToObjectConverter</code>, <code>EmptyCollectionToObjectConverter</code>, and <code>EmptyStringToObjectConverter</code></li><li>Added <code>CancellationToken</code> support to <code>IMessageBoxService</code> and <code>ILocationService</code></li><li><code>HamburgerMenuButton</code> will now allow parameter check for button highlighting</li><li>Improvements over the <code>INavigationService</code> interface and implementation</li><li>Other fixes and improvements</li></ul>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changing the Raspberry Pi Touch Display Rotation in Windows 10 IoT]]></title>
            <link>https://www.pedrolamas.com/2016/04/29/changing-the-raspberry-pi-touch-display-rotation-in-windows-10-iot/</link>
            <guid>https://www.pedrolamas.com/2016/04/29/changing-the-raspberry-pi-touch-display-rotation-in-windows-10-iot/</guid>
            <pubDate>Fri, 29 Apr 2016 12:48:03 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/dbddc275aaf2703d8404fe486cc85548/Windows-10-IoT-on-Raspberry-Pi.png" alt="Changing the Raspberry Pi Touch Display Rotation in Windows 10 IoT" class="webfeedsFeaturedVisual" /></p><p>If you have a <a href="https://www.raspberrypi.org/products/raspberry-pi-3-model-b/">Raspberry Pi 3</a> running <a href="https://developer.microsoft.com/en-us/windows/iot">Windows 10 Core IoT</a> and the <a href="https://www.raspberrypi.org/products/raspberry-pi-touch-display/">7” touch display</a>, then this post is for you!</p><p>Assuming you already installed the Windows 10 IoT in your Pi 3 and that it is currently up and connected to the network, you can open the Windows 10 IoT Core Dashboard, go to the “My Devices” tab and find your device listed there.</p><p>If you now click the “Open in Device Portal” option, the browser will launch, ask you to login with your credentials, and then show you the “Home” page of the Device Portal.</p><p>On the bottom you will find the “Display Orientation” option:</p><p><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:480px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:480px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:26.666666666666668%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAIAAADKYVtkAAAACXBIWXMAAA7BAAAOwQG4kWvtAAAAmUlEQVQY043COQ6CQBQA0Ll/YeNSW3gJGzsliAEGkCWuQAJChFmEGHT+fG9AfHlkGAbOedu0UkrGmBACAPR/CCLW8hNnza3q6g6rly74d3wpVN4MJXsTyZ7rQCytfkVhasLMVPM9jF9YMDH0JumJsd0lyel6OWfp/VEWoBSiHq81IGKa5oRS6lLfdqh1sB3XC6P4GEb/9PzgB57lDfoE5pR0AAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Display Orientation setting in the Device Portal" title="Display Orientation setting in the Device Portal" src="/static/dce6406d633a7291ef1f4ed9414729a0/e85cb/Display-Orientation.png" srcSet="/static/dce6406d633a7291ef1f4ed9414729a0/e9ff0/Display-Orientation.png 180w,/static/dce6406d633a7291ef1f4ed9414729a0/f21e7/Display-Orientation.png 360w,/static/dce6406d633a7291ef1f4ed9414729a0/e85cb/Display-Orientation.png 480w" sizes="(max-width: 480px) 100vw, 480px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">Display Orientation setting in the Device Portal</figcaption>
  </figure></p><p>Given my touch screen is placed upside down, I changed this setting to “Landscape (Flipped)”, and after rebooting the device I noticed that it flipped the touch screen display as requested, but it didn’t also flip the touch targets (so you’ll need to mentally rotate every point you touch on the screen to make it do what it is supposed to do)!</p><p>Under the hood, what this setting is doing is adding <code>display_rotation=2</code> to the Raspberry Pi “config.txt” file, but that’s not the proper way of doing this for the touch screen!</p><p>After reading the <a href="https://www.raspberrypi.org/documentation/hardware/display/troubleshooting.md">Raspberry Pi Display troubleshooting</a>, I realized that one should use <code>lcd_rotate=2</code> instead, which will rotate the lcd display and touch targets!</p><p>So the fix is quite easy: just open the <code>\\&lt;your-pi-ip-address&gt;\c$</code> network share, go to the “EFIESP” folder and inside of it, find and edit the “config.txt” file!</p><p>Remove any <code>display_rodate</code> entry and add <code>lcd_rotate=2</code> to the end of the file, save, reboot the Pi, and that should fix the problem completely! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit 2.2.0]]></title>
            <link>https://www.pedrolamas.com/2016/04/05/cimbalino-toolkit-2-2-0/</link>
            <guid>https://www.pedrolamas.com/2016/04/05/cimbalino-toolkit-2-2-0/</guid>
            <pubDate>Tue, 05 Apr 2016 16:12:33 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit 2.2.0" class="webfeedsFeaturedVisual" /></p><p><strong>Update: there was a packaging error in 2.2.0 which I already fixed and so the most current version is now 2.2.1!</strong></p><p><a href="http://cimbalino.org/"><strong>Cimbalino Toolkit</strong></a> version 2.2.0 is now available!</p><p>This new version includes improved support for Windows Phone Silverlight 8.1 (WP81) so that developers can take advantage of its specific <abbr title="Application Programming Interface">API</abbr>’s (such as the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.pickers.fileopenpicker.aspx">FileOpenPicker</a>)</p><p>This brings the total number of supported platforms to 5:</p><ul><li>Windows Phone Silverlight 8.0 apps (<abbr title="Windows Phone 8">WP8</abbr>)</li><li>Windows Phone Silverlight 8.1 apps (WP81)</li><li>Windows Phone 8.1 apps (WPA81)</li><li>Windows Store 8.1 apps (Win81)</li><li>Windows 10 <abbr title="Universal Windows Platform">UWP</abbr> apps (<abbr title="Universal Apps Platform">UAP</abbr>)</li></ul><p>Here’s the full change log for version 2.0.0:</p><ul><li>Improved compatibility with Windows Phone Silverlight 8.1 (WP81)</li><li>New <a href="https://www.nuget.org/packages/Cimbalino.Toolkit.Controls">Cimbalino.Toolkit.Controls</a> library (includes the <a href="/2016/03/07/cimbalino-toolkit-hamburger-controls-for-uwp/">HamburgerFrame for Windows 10</a>)</li><li>New IFilePickerService to handle the file picker (when available)</li><li>Improvements over the INavigationService implementation</li><li>Other fixes and improvements</li></ul>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit Hamburger controls for UWP]]></title>
            <link>https://www.pedrolamas.com/2016/03/07/cimbalino-toolkit-hamburger-controls-for-uwp/</link>
            <guid>https://www.pedrolamas.com/2016/03/07/cimbalino-toolkit-hamburger-controls-for-uwp/</guid>
            <pubDate>Mon, 07 Mar 2016 16:36:31 GMT</pubDate>
            <content:encoded><![CDATA[<p>Like it or not, the so called “Hamburger” design pattern has made its way to pretty much every platform, including the Windows Universal Apps!</p><p>Most Windows 10 native apps already show this new pattern, even a classic like the Calculator app!</p><p>However, for reasons unknown, Microsoft didn’t provide any Hamburger related control on the <abbr title="Software Development Kit">SDK</abbr> base controls… frankly, this move brings back to memory when Windows Phone 7 <abbr title="Software Development Kit">SDK</abbr> was launched without the <code>Panorama</code> and <code>Pivot</code> controls, the foundation of the whole “Metro” design guidelines!</p><p>The only alternative I’ve found is to use the <a href="http://aka.ms/Template10">Template 10</a>, a <em>“set of Visual Studio project templates”</em>!</p><p>However, I’ve found that Template 10 version for Hamburger adds a bit of too much “fat” for my own taste, hence why I’ve been working on an alternative for the past last few weeks!</p><h2>Introducing the Cimbalino Toolkit Controls</h2><p>Starting with version 2.2.0 (currently still in beta 1), the <a href="http://cimbalino.org"><strong>Cimbalino Toolkit</strong></a> will feature a new package called <strong>Cimbalino.Toolkit.Control</strong>, and as the name suggests, it’s a control library for app developers.</p><p>Currently, the package features 3 controls:</p><ul><li><strong>HamburgerFrame</strong></li><li><strong>HamburgerTitleBar</strong></li><li><strong>HamburgerMenuButton</strong></li></ul><h3>HamburgerFrame</h3><p>Starting from the top, the <code>HamburgerFrame</code> control is a full replacement for the native <a href="https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.frame">Frame</a> root control used in the <code>app.xaml.cs</code> file.</p><p>The control provides 3 content containers represented by the <code>Header</code>, <code>SubHeader</code>, and <code>Pane</code> properties, and on the center, it will show the navigated content:</p><p><a href="/eef04adceddfb85e2d0adbb3b772f071/HamburgerFrame.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:300px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:64.99999999999999%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7CAAAOwgEVKEqAAAABoUlEQVQoz32SbW+bMBSF+f8/pJ9a9UNUqWqlKt2SjEQRGFIKTSnkBQVUjSU2UBQwPtOd0/Rl66wjZF/uuX58baPXw90dLAu2/VmuS2Lsc9yyyHJ6CsO2AaDrcBxKKQBV9XM2+87Y7X5f6fAxQSdPJjCur7FcYj7H4+MHPTwoz9v7fvv0BK3jr/kciwV6PRj9Pp6fsVohy+A4ME2arNdIEmw2iOMmCMowrMOwXi67JKH4ek2Wy8tXbCnpm6aIIk1+gE/TxXh8a9s/JpNvnP/Sh9LYpvlqbpoOUGmKmxtqBmNE4TiYzeB5FPE8ap4OMkbL8/OPO282uL9H06AstZQQHect55JzKURXlqqqVFFQfr8Pw3UhZWlZjhB5liEMlcb+z9DYoxEMxgC0cbx6eeFH8x8WudvtttttnudFUQgh8jznnEspdenh8C/sMDxcaVVVrutOp1PTNKMoCoKAMeb7fl3XujqZLUs3TAEqSegada2vyLsObUuTweCAfdg5yxDHeHdm9S/h7arOzuihDQa0uLrCxQXGY0Iajb7UcEiWkxP8BoW20BBtGV9wAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="HamburgerFrame container thumb" title="HamburgerFrame container thumb" src="/static/3ba4bfa8eaf6a40e5f52f47c6ced75ea/5a46d/HamburgerFrame-thumb.png" srcSet="/static/3ba4bfa8eaf6a40e5f52f47c6ced75ea/e9ff0/HamburgerFrame-thumb.png 180w,/static/3ba4bfa8eaf6a40e5f52f47c6ced75ea/5a46d/HamburgerFrame-thumb.png 300w" sizes="(max-width: 300px) 100vw, 300px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Obviously, you can specify content for this containers however you would like, or just leave them blank!</p><p>The <code>Header</code> allows content to be presented above the <code>Pane</code>, so it will never be hidden by it:</p><p><a href="/369b149f5d00ef6262d15c3829891a30/HamburgerFrame-Header-only.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:300px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:64.99999999999999%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7BAAAOwQG4kWvtAAABVUlEQVQoz6VSXWvCMBTt//8hPulTEURfZGv9ekhrtQVjadV+GHR7mMxia5IzYqrMwsZg4RCSe+/JORximCaWSxACx2nC8xRct1knRFHabRiOAwBC4LGklADO57fF4tV1X8ryrMuPAT08m8EYDLDdglKs109YraTvl75fUiobLUqx2cA0YQyHOByw24ExzOeYTtUhSZBlyHOFNG0iSRSl17vb5lzt+z2iSDvHL0vbHo/v5KoSgMwy5Uq3pYQQUgjJuXw+1EqW9ayc5wjDvyrbNgzPA+efhMxPp3fGsF5LHWxRFJTSIAg8z0uSJI7jIAjCMLxcLvoJRXZdANc43hXFB2MIw1q0LEvNiaLoeDwyxtI0ZYxVVaV9KfK/bBOiA1Nu07QOjHPcgpEa32MTAtfrPbCb7VqZMcTxX5UnExidjvpolqUu/T66XfVPbBuj0Y+wbUVptfAFGQbYOWLzG8kAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="HamburgerFrame container thumb" title="HamburgerFrame container thumb" src="/static/72756421e668db360a864e3d572ecc5c/5a46d/HamburgerFrame-Header-only-thumb.png" srcSet="/static/72756421e668db360a864e3d572ecc5c/e9ff0/HamburgerFrame-Header-only-thumb.png 180w,/static/72756421e668db360a864e3d572ecc5c/5a46d/HamburgerFrame-Header-only-thumb.png 300w" sizes="(max-width: 300px) 100vw, 300px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>The <code>SubHeader</code> allows content to be presented on the right side of the <code>Pane</code>. This means that if the pane is in one of the “overflow” modes it will show on top of this container, hiding the content behind it:</p><p><a href="/228185e9c1f428301b09b442344874a7/HamburgerFrame-SubHeader-only.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:300px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:64.99999999999999%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7BAAAOwQG4kWvtAAABZ0lEQVQoz41S0U7CMBTd/38IT/qEJoTgi2yAErdZYIExNpPVWkbwSXCMtsfcFQQeNDQnze29PT2nt3Xu7hBFCAKMx+h20emAMfg+ZYIAYYjXV8qMRhTbpO/T5psbOEEAAErRLCXe3igwBsYYAEWRvrw8TCY9xh43m8+6ZLSmPc/PcHyfoqqiWQh4HtIUcYz5nDCdqsmkqrGbzbRNxjFpNJuXyh8fGA5JP8/BOeH9nU60sBnOqVoUaLUuyUJgsTjY/mdY2/0+nDCk5fd3BRghyJUtGwOtjdZGKXMZHJRcFw5jUOrLdfvrtVwuMZ+bK5U972i7LPeAFgJJQlwA2+02juMoihhjeZ5nWRZFUZIkZVnaI07k3zvXZBq73c5y0jRdrVZSSs65lLKqKuvrT/K1ts/fmfNDw5RC3Rhjcd42rbHfHxtWd/v0w7LsWuXBAM7tLX0016VFu437ezw9kaVe7094HlEaDfwAQ8XYrKZUQgUAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="HamburgerFrame container thumb" title="HamburgerFrame container thumb" src="/static/595ec59417c279fa145068eb2e9fa957/5a46d/HamburgerFrame-SubHeader-only-thumb.png" srcSet="/static/595ec59417c279fa145068eb2e9fa957/e9ff0/HamburgerFrame-SubHeader-only-thumb.png 180w,/static/595ec59417c279fa145068eb2e9fa957/5a46d/HamburgerFrame-SubHeader-only-thumb.png 300w" sizes="(max-width: 300px) 100vw, 300px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>The control also provides background properties for all these containers (<code>HeaderBackground</code>, <code>SubHeaderBackground</code>, and <code>PaneBackground</code>).</p><p>To make the life easier of developers, I’ve “borrowed” the <code>VisualStateNarrowMinWidth</code>, <code>VisualStateNormalMinWidth</code>, and <code>VisualStateWideMinWidth</code> properties from Template 10, which allow to specify the break points where the pane state and location will readjust. If you don’t want to use these, you can always do it manually with the exposed pane related properties (<code>IsPaneOpen</code>, <code>DisplayMode</code>, <code>OpenPaneLength</code>, <code>CompactPaneLength</code>, …).</p><h3>HamburgerTitleBar</h3><p>The <code>HamburgerTitleBar</code> control provides a basic Hamburger button on the left side (can be hidden with the <code>MenuButtonVisibility</code> property), and a <code>Title</code> property.</p><p><a href="/4873e2c095c9ed18054aaac9e55e8cac/HamburgerTitleBar.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:400px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:12.222222222222221%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAACCAIAAADXZGvcAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAMUlEQVQI12N49uzZvXv33r17t3fv3rVr1169evX79+8fP378RARg+AwGnz59gjOIBwAfZW9YfyJu2gAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="HamburgerTitleBar" title="HamburgerTitleBar" src="/static/4873e2c095c9ed18054aaac9e55e8cac/e17e5/HamburgerTitleBar.png" srcSet="/static/4873e2c095c9ed18054aaac9e55e8cac/e9ff0/HamburgerTitleBar.png 180w,/static/4873e2c095c9ed18054aaac9e55e8cac/f21e7/HamburgerTitleBar.png 360w,/static/4873e2c095c9ed18054aaac9e55e8cac/e17e5/HamburgerTitleBar.png 400w" sizes="(max-width: 400px) 100vw, 400px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>This is a quite rudimentar and easy to use control, yet developers might want to just go ahead and create their own version of this control and place it on their apps!</p><h3>HamburgerMenuButton</h3><p>Finally, the <code>HamburgerMenuButton</code> is the button you’ll be using in the pane to indicate the available menu options!</p><p>This control shows a left-side icon and an optional label (through the <code>Icon</code> and <code>Content</code> properties):</p><p><a href="/d184dc5f0d05556213babab62a6623c0/HamburgerMenuButton-basic-states.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:374px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:24.444444444444443%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAIAAADKYVtkAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABBElEQVQY002LP0vDQByGb2hBdOrgB3PyK7goSBvRqkPxezg4uDq1Q/wGBZHEtPmHSkykSWp6d0nJXe4u+UlaUR+e5X3gRbBBiGq9XueUSinhH3UNqgYhVZqk8SJefmUrQngl66btqGkaAMiWqWka1otVlgwANu0PpeSrOfWN6dv8OX63a1ltOxJCcM6VUttdVRXnnDEmZVvunsjRw0KbpOePVNPJmY4vdDyYpP1x0h8nyHVdjHEQBKZp+L5XFAWlFBNSMg4AB7cfaDDvns462qw3cvYubXRsohPrxyiKCCFZloVhGMdxURR5nlNKGW/Ph/ef3aG9c+XsXrv7N15v5HWGzq/fZzL4UTM7SIQAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="HamburgerMenuButton basic states" title="HamburgerMenuButton basic states" src="/static/d184dc5f0d05556213babab62a6623c0/52dba/HamburgerMenuButton-basic-states.png" srcSet="/static/d184dc5f0d05556213babab62a6623c0/e9ff0/HamburgerMenuButton-basic-states.png 180w,/static/d184dc5f0d05556213babab62a6623c0/f21e7/HamburgerMenuButton-basic-states.png 360w,/static/d184dc5f0d05556213babab62a6623c0/52dba/HamburgerMenuButton-basic-states.png 374w" sizes="(max-width: 374px) 100vw, 374px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>The regular approach here will be to just place all the <code>HamburgerMenuButton</code> controls inside a vertical <code>StackPanel</code>, but one can also stack them horizontally, and in this case, we would only show the icon and hide the label (using the provided <code>LabelVisibility</code> property).</p><p>The <code>NavigationSourcePageType</code> property allow developers to specify the destination page type for navigation purposes. If the property is set, the button will automatically highlight anytime the page is the frame current navigation content.</p><h2>So how can I use these in my app?</h2><p>First step is to add the <a href="https://www.nuget.org/packages/Cimbalino.Toolkit.Controls/">Cimbalino.Toolkit.Controls</a> NuGet package to the project!</p><p>Then, create a new user control to define your menu; in it, add as many <code>HamburgerMenuButton</code> instances as the number of options you want to present!</p><p>Here’s how your menu might look like:</p><pre><code class="language-xml">&lt;UserControl x:Class=&quot;App1.View.HamburgerPaneControl&quot;
             xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
             xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
             xmlns:controls=&quot;using:Cimbalino.Toolkit.Controls&quot;
             xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
             xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
             xmlns:view=&quot;using:App1.View&quot;
             d:DesignHeight=&quot;300&quot;
             d:DesignWidth=&quot;400&quot;
             mc:Ignorable=&quot;d&quot;&gt;

    &lt;Grid&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition /&gt;
            &lt;RowDefinition Height=&quot;Auto&quot; /&gt;
        &lt;/Grid.RowDefinitions&gt;

        &lt;StackPanel&gt;
            &lt;controls:HamburgerMenuButton Content=&quot;Home&quot; NavigationSourcePageType=&quot;view:MainPage&quot;&gt;
                &lt;controls:HamburgerMenuButton.Icon&gt;
                    &lt;FontIcon FontSize=&quot;16&quot; Glyph=&quot;&amp; #xE80F;&quot; /&gt;
                &lt;/controls:HamburgerMenuButton.Icon&gt;
            &lt;/controls:HamburgerMenuButton&gt;

            &lt;controls:HamburgerMenuButton Content=&quot;Details&quot; NavigationSourcePageType=&quot;view:DetailsPage&quot;&gt;
                &lt;controls:HamburgerMenuButton.Icon&gt;
                    &lt;FontIcon FontSize=&quot;16&quot; Glyph=&quot;&amp; #xE8BC;&quot; /&gt;
                &lt;/controls:HamburgerMenuButton.Icon&gt;
            &lt;/controls:HamburgerMenuButton&gt;
        &lt;/StackPanel&gt;

        &lt;controls:HamburgerMenuButton Grid.Row=&quot;1&quot;
                                  Content=&quot;Settings&quot;
                                  NavigationSourcePageType=&quot;view:SettingsPage&quot;&gt;
            &lt;controls:HamburgerMenuButton.Icon&gt;
                &lt;FontIcon FontSize=&quot;16&quot; Glyph=&quot;&amp; #xE713;&quot; /&gt;
            &lt;/controls:HamburgerMenuButton.Icon&gt;
        &lt;/controls:HamburgerMenuButton&gt;
    &lt;/Grid&gt;
&lt;/UserControl&gt;
</code></pre><p>Next, open the app.xaml.cs file and replace this line:</p><pre><code class="language-csharp">rootFrame = new Frame();
</code></pre><p>with this:</p><pre><code class="language-csharp">rootFrame = new Cimbalino.Toolkit.Controls.HamburgerFrame()
{
    Header = new Cimbalino.Toolkit.Controls.HamburgerTitleBar()
    {
        Title = &quot;App1&quot;
    },
    Pane = new View.HamburgerPaneControl()
}
</code></pre><p><strong>Congratulation:</strong> your app now has a universal Hamburger menu with a nice title bar! :)</p><p><a href="/e7419eb82b6ef5b8a1f7f7bd64a692cd/App-with-HamburgerFrame.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:480px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:71.66666666666667%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABSklEQVQoz52TTWsCMRCG9ydL/U9CvZfSQ8+9FA+FIthDl3Vd7cbsNjGZZCZfZXdFWrVfPswpk4cM75DMqtajTomGcoTG7gEADWDPAQBSymw0WYwmL+NpPp7mV9f5fLVLgaxFRKQePAcRAUB287i8na3unuqhuKKUUky/473PSL8Hu4uohkrBp7/Rybxphdy1QrZCNq0gcj8IMcbDWN67jDHGORc9SusQ4z9eFlIKKY3pMq7rTVku1U6lFEOP7wkhxBiFEGVZNrwZWs65LDrryFrbBchYXRSFFJKoO1JKOed0DyJyzvP8lTGGiABgjMkeFtvZokKjjTFI5J1HtKYHAIZ72+1WKUVE3nsiOnSz+2c2r6APIx0tKcY4CF8D29ON7YxOwX2X7ZH8mU5WSpO7XO5SuVCuqqooirqu307YbDbDB1iv16etpmk+APrIKWf0jbUtAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="App with HamburgerFrame" title="App with HamburgerFrame" src="/static/98e685bce6198a7d0b7a5f3c1d7f3a9a/e85cb/App-with-HamburgerFrame-thumb.png" srcSet="/static/98e685bce6198a7d0b7a5f3c1d7f3a9a/e9ff0/App-with-HamburgerFrame-thumb.png 180w,/static/98e685bce6198a7d0b7a5f3c1d7f3a9a/f21e7/App-with-HamburgerFrame-thumb.png 360w,/static/98e685bce6198a7d0b7a5f3c1d7f3a9a/e85cb/App-with-HamburgerFrame-thumb.png 480w" sizes="(max-width: 480px) 100vw, 480px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Next steps might be to create a separate user control to hold the <code>HamburgerTitleBar</code>, which will then allow you to bind the <code>Title</code> property to view model (making it easier to update on a page by page basis).</p><p>To make things easier, I’ve provided the <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/tree/master/samples/HamburgerFrame">source code</a> for a simple app using these controls!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Still Strong-Naming your Assemblies? You do know it's 2016, right?]]></title>
            <link>https://www.pedrolamas.com/2016/03/01/still-strong-naming-your-assemblies-you-do-know-its-2016-right/</link>
            <guid>https://www.pedrolamas.com/2016/03/01/still-strong-naming-your-assemblies-you-do-know-its-2016-right/</guid>
            <pubDate>Tue, 01 Mar 2016 15:56:14 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/9df7db153d98902557ef1e87b86f2547/We-Want-You-To-Stop-Strong-Naming-Assemblies.png" alt="Still Strong-Naming your Assemblies? You do know it's 2016, right?" class="webfeedsFeaturedVisual" /></p><p><strong>Update:</strong> Though the information and concerns in this blog post are still very true, I’ve actually had a change of heart and I’m now advocating to <a href="/2018/09/11/start-strong-naming-your-assemblies/">Start Strong-Naming your Assemblies!</a>!</p><hr/><p>For far to long, Strong-Named Assemblies have been a huge rock in the shoe of 3rd party library developers, but people: it’s 2016, so why are you still using it?</p><h2>How it all started…</h2><p>The year was 2002 (or so I believe!), Microsoft had just released the .NET Framework, and one of the main enterprise focused features was the ability to sign an assembly with a strong-name.</p><p>Back then, Strong-Named Assemblies had some great advantages, as indicated in <a href="https://msdn.microsoft.com/en-us/library/wd40t7ad(v=vs.110).aspx">this</a> <abbr title="Microsoft Developer Network">MSDN</abbr> article:</p><blockquote><ul><li>You want to enable your assemblies to be referenced by strong-named assemblies, or you want to give friend access to your assemblies from other strong-named assemblies.</li><li>An app needs access to different versions of the same assembly. This means you need different versions of an assembly to load side by side in the same app domain without conflict. For example, if different extensions of an <abbr title="Application Programming Interface">API</abbr> exist in assemblies that have the same simple name, strong-naming provides a unique identity for each version of the assembly.</li><li>You do not want to negatively affect performance of apps using your assembly, so you want the assembly to be domain neutral. This requires strong-naming because a domain-neutral assembly must be installed in the global assembly cache.</li><li>When you want to centralize servicing for your app by applying publisher policy, which means the assembly must be installed in the global assembly cache.</li></ul></blockquote><p>So strong-named assemblies are uniquely identified, which is a good thing, until it starts to work against you…</p><p>Let’s look at a real example: a few years back, <a href="http://json.net/"><abbr title="JavaScript Object Notation">JSON</abbr>.net</a> was actually a strongly-signed assembly. Now let’s assume we have a project that depends on “LibraryA” and “LibraryB”, and each of these require a different version of <abbr title="JavaScript Object Notation">JSON</abbr>.net.</p><p><a href="/44d1b5f35138e97bc154652aae212d12/Before-Assembly-Binding-Redirection.png"><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:235px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:235px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:118.88888888888889%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAD+0lEQVQ4y42T708adxzH7/9o+qTZphVCTbcImw+qVNOYDrmbVluHIKBEJnonFqTFLfKAdZrKDkhtMmjr7wNB1ww8UPaArH1iMQpkcR22abW2mFZojKYI3I/lYDMyfNBvLpf7fvJ+fT75fvM6QH0nIv4x1HYrJLnFvOVDK82Dy9OBLZqmSZIiSYqm6anAVvPgsnxoRZJLSn8KiY0h9Z0IAN0I8hQ4v2fpYs/Sha7FatXSOYkHnV2naZogKSIHo86/zkk81d1LNXCgSrV4oWuRp/BBN4MAqMG5MlezflFqCIh+CICaBfY1DHVECmAswr6GCTV4G5NZatb7uTIXqMUBAez64tsHFa3jAsRdp3LyJOPsRtvI5JPj8MjkMrvR9qVkokoxA6rnvmqb+LzlQT3iAqpk9k8vm8pAlAWay0CUDVlO1QwZbUEGJkiCIGmaNtqCp2qG2JCFBaIsyFwGmj+5bKqW2QHt7d/keqxzcFasm5HpMaXBJdJOOvDV4xfmWFgVaSeVBpdMj0l0M52Ds3I91n/bA9A0TTEB+uWbveReitnSJ6x8MbmX2ozvHSFAOkOk0gRJUU9fJuK7BwRJpdJElijokCWYIkFS8d2D2GaCpJhtOkPkJzPRtac78d2Do67/n5wrxt/th//eOUIAw9g6bA1fH42q0DXYEtbcjSpNq78+en38zPN/vFaaVjV3o7AlrELXro9GYWvYML4OCHXBig4fT+HjdjBPZaefI/H+7CyQxORY50i8lZ3+fIbb4avo8IE3ggCkxblSF6jBIQ0u6Fuogz2cFgx1hAslCXNasDrY09Dvg7Q4pMV5MhfESIK4z7eMCWA3qHbX97prlY6zDTbTVKhQkiel39hqlA5Q7Qb75r6GXQyCuAF++/2SerRUaC4VmkvqURZkOV07nJckkyUyWYKR5Jfg6dphFmT5TICW5sIlApTffh/oNs5f7ZsQ66av9I6LtFPtA44mZGzas1LwV3lWmpAx+YBD1D/V1Dsu1k1f7ZvoMc4DFPVv4s27/XBs59l2MraViG0lnm+/j268jW68fb79Pl95tp2MxHbiu/v5vhRFAfmDEbkhh+ls6jB7kMrsf8gQJLXxKrnxKkmQ1P6HzEEqkzrMHqaz5H95gqQA+kQZcw7ENhOxzcTRtngBxQLbvS8QS+Sm7U/EuoZY15gPS8TufVGsPVDsIGwOlbd5K5V+roKRp1LpL2/zIuZQsbknwL3o4/JW5yXYA2n9Qo3vUo+nvNXZiz7+KLh7OMC6co+vwOqROUg9x1dgrMZ7PcO/fxSsMDw8U2fiNFjP5szhNFjP1I0oDA+Lb+4EeMCCX5SOCrvsAqVN8J1N2GXnS0e/t+DFk/8BJE8l9qNoEAkAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Before Assembly Binding Redirection" title="Before Assembly Binding Redirection" src="/static/2785a890f4879eb6ba3d655ff158124c/6783b/Before-Assembly-Binding-Redirection-thumb.png" srcSet="/static/2785a890f4879eb6ba3d655ff158124c/e9ff0/Before-Assembly-Binding-Redirection-thumb.png 180w,/static/2785a890f4879eb6ba3d655ff158124c/6783b/Before-Assembly-Binding-Redirection-thumb.png 235w" sizes="(max-width: 235px) 100vw, 235px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">Before Assembly Binding Redirection</figcaption>
  </figure></a></p><p>If you build the project as it currently is, there will be a conflict as you can only have a single version of <abbr title="JavaScript Object Notation">JSON</abbr>.net on the output folder, but the libraries require different versions…</p><p>To fix this issue, .NET provided a mechanism called <a href="https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx">Assembly Binding Redirection</a> to ensure that only one specific assembly would be used, regardless of the required version.</p><p><a href="/70f5833bc1eda57c3799f4a14f5866c2/After-Assembly-Binding-Redirection.png"><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:235px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:235px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:118.88888888888889%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAEK0lEQVQ4y42S/U+aVxTHn79jSX9plmlLw8yWVDd/WGtrGrMhPLO1nbHiK5H5AmhB19ptZnPrzKS8ZDYptlOrBSe6JjCgdcnM1iVTVF5UUECRFwUeeaAVFHje7gJUY6dLenJ+uOfc7+fee849kGszZtvYsXte+Yp3Z9n9MhRJAgAoAEiSAgCMTHmvfj1T98Mc+ztj9ffGmjvGqh5j208WaGk9Or+Cmp0RszNicqAmB2q0h/3IbhqmAJGBJWP2d9ma8y3PLvKmzjU//ajpaQFHD9+chpbW0Hk7sryO2t0Rmzuy6ArPLgf9odhrsNJy5jMlU6ir7p6q/PLZ1VuG/NpxlkgHLbqQOVtg3hawOhGrMzRvD8wub/lCO4fhvkczZy4rPmAPn+M8ZrVNfFg9/H7Fz6X8cchk3/rH4p1d9M1Y0z5r9f1t8mxsRkGmYBwnAQDf3v/jrQt3aLD0NFNCY0lPs6Rvfyw+XzsArfnQlXVk1Y04Pdtr3rDLG151I+FoHGQs27AxvYndOdr8jbr+tqqq83HjV7/U3VJ2/KiBwL69iCU9gZfBcDwQjge245tIbGvfg2g8hO6GX+ytuMNObyRbEQAAwgkKw9NrPxLbju5hOJlI4SmcwAkKJ0icIAmCSqSI2B6WwghfaGd1AyWpdCaFEdDBMYsuJITuHoT/sWwyEI6ZV4OZMB1D3YM2ntx8o9/adHehVWYS3lvkihd+/WszW3C25sk/N7niBeE9K09mbpaYbvRbeXJz95ANYnZOn23QF3D0+Q36ggZ9YaOBztbeHbMBkP6n7FeJVTY6W1vYaMhv0Gf9bIOe9cU0BIt0+TXjLKEOFuoY7b+V8DT0CqVEZT4MS5RmeoWyhKcp69DDIh0s0hXUjsMiHcTgq9+rGGTw1Kw2dalAXcxVnSpTiEeMh+G+R7O5nyouclWsNjWrfeIT3nga4auhovqHOaWSXKY0lynNKZXQYNmJ4t4exTQAAMMJDCcAAD33p08U99Jg2TsMSW5GnMOQFNU/hFp6Jq+1D1d1jl4RDFWKRuq7VOX8wVHN3OGGjWjmyvmDdV2qyo6RcsFQVefotfbh1p5JiKJeKba2Y2ZH0OWPOLyow4uu+aOZaUfW/NFsxuWPWBzBQDiWPZeiKChbGJG5JJnCE0k8nsBiexhBUk5fxOmLECQV28PiCSyRxJMpnNzXEyQFAXDsSKTf4vCgDg96EB611+CsZEDr5sssNxVLfLmJLzelFzLLgNZ9IPgfOLPJkxrzqrWFXEM+Jz08hVxDXrWWLzUendxjYIHked71sUs8DSwyMIX6S62avOtjAsnzN4JbeqdoVx4UcZSl/Am4baKIo6RdftDa+/sbwZzuJydLxPQy+anM5NDL5CdL+jjdT4527hi4S6a7UNPPbBpgcBWMzxXMpoGimv7bMt3Rm/8F2pNZ8+jCZTIAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="After Assembly Binding Redirection" title="After Assembly Binding Redirection" src="/static/d9fe0dcfec446a6ba13c1f7c539027e0/6783b/After-Assembly-Binding-Redirection-thumb.png" srcSet="/static/d9fe0dcfec446a6ba13c1f7c539027e0/e9ff0/After-Assembly-Binding-Redirection-thumb.png 180w,/static/d9fe0dcfec446a6ba13c1f7c539027e0/6783b/After-Assembly-Binding-Redirection-thumb.png 235w" sizes="(max-width: 235px) 100vw, 235px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">After Assembly Binding Redirection</figcaption>
  </figure></a></p><h2>In comes Silverlight and Windows Phone</h2><p>Unfortunately, neither Silverlight nor Windows Phone support Assembly Binding Redirection… and that is where the true problems started.</p><p>There are <a href="https://github.com/octokit/octokit.net/issues/405">quite</a> <a href="https://github.com/libgit2/libgit2sharp/issues/212">a</a> <a href="http://jeremydmiller.com/2014/04/28/fubumvc-lessons-learned-strong-naming-woes-and-workarounds/">few</a> threads around this issue over the internet, and in the end, a lot of 3rd party library developers just <a href="http://james.newtonking.com/archive/2012/02/11/json-net-4-0-release-8-bug-fixes">decided to stop strong-naming their assemblies!</a></p><p>Others, followed the advice of the <abbr title="Microsoft Developer Network">MSDN</abbr> article I pointed above:</p><blockquote><p>If you are an open-source developer and you want the identity benefits of a strong-named assembly, consider checking in the private key associated with an assembly into your source control system.</p></blockquote><p>Obviously, for this to work you would have to build your own versions of your project dependencies… and let’s be honest here: that will eventually be more of a problem that a solution.</p><p>A few years ago, I personally felt this pain while developing a Windows Phone app, and so I went to the <a href="https://wpdev.uservoice.com">Windows Phone Developers UserVoice website</a> and <a href="https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/2511980-assembly-binding-redirection-support">requested</a> the support for Assembly Binding Redirection on Windows Phone… almost a year after the request, I got an update indicating it was “on the backlog”, and seems it has stayed like that till now…</p><h2>If it is such a bad thing, why are people still doing it?</h2><p>Developers seem to have the wrong notion that they should strong-name their assemblies as a security feature, but this could not be further away from the truth!</p><p>Granted, that does provide a basic insurance that an assembly hasn’t been tampered/altered, but in any case one can always use binding redirection (when available) to bypass the whole thing, so that is just a lame excuse to not buy a proper Code Signing Certificate and apply Authenticode to the assembly (which will prevent tampering AND impersonation, the right way!).</p><h2>What about the Universal Windows Platform?</h2><p>Unfortunately, as far as I know there is no support for Assembly Binding Redirection in <abbr title="Universal Windows Platform">UWP</abbr>…</p><p>A couple of weeks ago, Microsoft open-sourced the <a href="https://github.com/Microsoft/XamlBehaviors"><abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors</a> and guess what? Yes you guessed correctly: <a href="https://github.com/Microsoft/XamlBehaviors/pull/29">they strongly-signed it!</a></p><p>Fortunately, after a long debate on that same thread, they realized that it made no sense to do that, and <a href="/2016/02/23/xaml-behaviors-uwp-managed-1-1-0/">removed the strong-name signing on the latest version!</a></p><h2>Bottom line</h2><p>With this article I tried to make the point that Strong-Named Assemblies are just legacy of the “old” .NET Framework days, and have no place in the modern Universal Windows Platform.</p><p>Hopefully, 3rd party developers will continuously provide non-strongly-named assemblies which will make a lot of developers happy.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XAML Behaviors UWP Managed 1.1.0]]></title>
            <link>https://www.pedrolamas.com/2016/02/23/xaml-behaviors-uwp-managed-1-1-0/</link>
            <guid>https://www.pedrolamas.com/2016/02/23/xaml-behaviors-uwp-managed-1-1-0/</guid>
            <pubDate>Tue, 23 Feb 2016 10:32:23 GMT</pubDate>
            <content:encoded><![CDATA[<p>The <a href="https://github.com/Microsoft/XamlBehaviors"><strong><abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors for <abbr title="Universal Windows Platform">UWP</abbr></strong></a> has just been updated to version 1.1.0.</p><p>Among other changes, this version contains two fixes that I personally contributed for issues found in the <code>EventTriggerBehavior</code>:</p><ul><li><a href="https://github.com/Microsoft/XamlBehaviors/commit/2ad49665200730a25ea61e1bd950ea5887989468">Ensured EventTriggerBehavior unregisters the event handler</a></li><li><a href="https://github.com/Microsoft/XamlBehaviors/commit/71bf9ba628d562f56418b122d9b08bd0a6ff7c55">Properly check for Windows Runtime events in EventTriggerBehavior</a></li></ul><p>The <a href="https://www.nuget.org/packages/Microsoft.Xaml.Behaviors.Uwp.Managed/">NuGet package</a> has been updated so if you’re using the Xaml Behaviors in your app, all you need is to let NuGet take the latest version of the package!</p><p>In the next days I’ll be releasing a new version of the <a href="http://cimbalino.org"><strong>Cimbalino Toolkit</strong></a> to take this updated Xaml Behaviors package.</p><p><strong>Update 24/02/2016:</strong></p><p>I forgot to mention a massive difference on the new version of the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors:</p><p>If you use PowerShell to output the Assembly Full Name from the current and previous versions of the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors, this is what you will get:</p><p><a href="/b0864069ce1f0e195200e430a6016a91/Microsoft.Xaml_.Interactivity-assembly-full-name.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:14.444444444444443%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAIAAAAcOLh5AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAwklEQVQI1wG3AEj/ALS8yLa8xrrAy8TL1cXM1cXL1cbN18nP2cfO173H0sDH0cHI0cHI0cPJ0sTJ0rzG0brF0MDI0rvEz8jLzgAkQW0gPmohPmoZOGQePGgfPGgePWklQm0iQWwUNWEnNV0pNl4oNV0jNV4gNFwIK1kBKloVNWMGKFqNl6UADi9eCitbDC1dCipbCyxcCixbCCpbDC1dDS5eCipZFSlWGCtYFylXBCNUACNVACRWACRWBShYABxQlJ+tt09KhMbTllYAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Microsoft.Xaml.Interactivity assembly full name" title="Microsoft.Xaml.Interactivity assembly full name" src="/static/b0864069ce1f0e195200e430a6016a91/37523/Microsoft.Xaml_.Interactivity-assembly-full-name.png" srcSet="/static/b0864069ce1f0e195200e430a6016a91/e9ff0/Microsoft.Xaml_.Interactivity-assembly-full-name.png 180w,/static/b0864069ce1f0e195200e430a6016a91/f21e7/Microsoft.Xaml_.Interactivity-assembly-full-name.png 360w,/static/b0864069ce1f0e195200e430a6016a91/37523/Microsoft.Xaml_.Interactivity-assembly-full-name.png 720w,/static/b0864069ce1f0e195200e430a6016a91/39a20/Microsoft.Xaml_.Interactivity-assembly-full-name.png 859w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Notice the different <code>PublicKey</code> value?</p><p>Well, after a <a href="https://github.com/Microsoft/XamlBehaviors/pull/29#issuecomment-162572491">long discussion</a> about it, seems Microsoft has finally decided in <a href="https://github.com/Microsoft/XamlBehaviors/commit/ceb2f68109c032ab997e9c5bb43aebadf81cfbcf">removing the StrongName signing</a>!</p><p>Though this might not sound as an important change, it is fundamentally a sign of ditching the “old” legacy .NET Framework stuff.</p><p>But I’ll leave that for a next post… ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Awaiting the CoreDispatcher]]></title>
            <link>https://www.pedrolamas.com/2016/01/20/awaiting-the-coredispatcher/</link>
            <guid>https://www.pedrolamas.com/2016/01/20/awaiting-the-coredispatcher/</guid>
            <pubDate>Wed, 20 Jan 2016 10:29:19 GMT</pubDate>
            <content:encoded><![CDATA[<p>Most programming language allow you to take advantage of multi-threaded execution, and .NET is no exception!</p><p>Asynchronous code is a modern abstraction of multi-threading execution, and as you hopefully are aware, in .NET land, this is achieved with the <code>async</code> and <code>await</code> keywords.</p><p>For the Universal Windows Platform, we can also count on the <a href="https://msdn.microsoft.com/library/windows/apps/windows.ui.core.coredispatcher.aspx">CoreDispatcher</a> class to marshal execution back to the main thread, from which we can update the <abbr title="User Interface">UI</abbr> of our apps.</p><p>Here’s a simple example of how to use it:</p><pre><code class="language-csharp">public async void DoStuff()
{
    var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;

    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =&gt;
    {
        UpdateUI();
    });

    DoOtherStuff();
}
</code></pre><p>Assuming we are on a background thread when the <code>DoStuff()</code> method is invoked, we will retrieve a <code>CoreDispatcher</code> instance from the <code>CoreWindow.CoreDispatcher</code> property, call and await for the execution of <code>dispatcher.RunAsync()</code> method, which in turn will invoke the <code>UpdateUI()</code> method on the main thread, and then code execution will continue in the background thread by invoking the <code>DoOtherStuff()</code> method.</p><p>As it is right now, we know that <code>DoOtherStuff</code> will only execute <strong>after</strong> the <code>UpdateUI()</code> method finishes, but now let’s assume that we replace the <code>UpdateUI()</code> synchronous method with an asynchronous version of it, called <code>UpdateUIAsync()</code>:</p><pre><code class="language-csharp">public async void DoStuff()
{
    var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;

    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =&gt;
    {
        await UpdateUIAsync();
    });

    DoOtherStuff();
}
</code></pre><p>In this new version of the code, you’ll notice that the <code>DoOtherStuff()</code> method will eventually run before the <code>UpdateUIAsync()</code> has finished, which might not be what you intended to in the first place when you await’ed for the <code>dispatcher.RunAsync()</code> method!</p><p>This is due to the fact that the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.core.coredispatcher.runasync.aspx">CoreDispatcher.RunAsync</a> method has a <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.core.dispatchedhandler.aspx">DispatchedHandler</a> callback which is not asynchronous:</p><pre><code class="language-csharp">public delegate void DispatchedHandler()
</code></pre><p>The fact that we’ve added the <code>async/await</code> keywords to the callback doesn’t ensure that the caller will await for it to execute!</p><p>There are a few ways suspend the background thread execution until the foreground thread signals for it to continue, and using a <a href="https://msdn.microsoft.com/en-us/library/dd449174(v=vs.110).aspx">TaskCompletionSource&lt;T&gt;</a> is one of the easiest:</p><pre><code class="language-csharp">public async void DoStuff()
{
    var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
    var taskCompletionSource = new TaskCompletionSource&lt;bool&gt;();

    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =&gt;
    {
        await UpdateUIAsync();

        taskCompletionSource.SetResult(true);
    });

    await taskCompletionSource.Task;

    DoOtherStuff();
}
</code></pre><p>In this version of the code, once the execution returns from await’ing the <code>dispatcher.RunAsync()</code> call, the background thread will carry on execution, but will then await for the <code>taskCompletionSource.Task</code> to finish, which will only happen after the <code>taskCompletionSource.SetResult(true)</code> call that we make in the main thread!</p><p>I’ve written a few <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit.Core%20(WP8)/Extensions/CoreDispatcherExtensions.cs">CoreDispatcher extension methods</a> to help around this issue, and added them to the next version of the <a href="http://cimbalino.org">Cimbalino Toolkit</a>, but you can access them right now if you wish so! ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiled Bindings considerations II]]></title>
            <link>https://www.pedrolamas.com/2016/01/08/compiled-bindings-considerations-ii/</link>
            <guid>https://www.pedrolamas.com/2016/01/08/compiled-bindings-considerations-ii/</guid>
            <pubDate>Fri, 08 Jan 2016 16:02:34 GMT</pubDate>
            <content:encoded><![CDATA[<p><strong>Update:</strong> Microsoft has finally provided a fix for this bug, covered in the <a href="/2018/01/31/compiled-bindings-considerations-iii/">Compiled Bindings considerations III</a> article!</p><p>A few months ago I wrote my first <a href="/2015/10/19/compiled-bindings-considerations/">Compiled Bindings considerations</a> article, and seems that time has come to write some more, only this time I’m bearer of some bad news…</p><h2><abbr title="Too Long">TL</abbr>;<abbr title="Didn&#x27;t Read">DR</abbr></h2><p>Compiled Bindings have a bug, noticeable in some scenarios, specifically when a binding has a fallback value of null (which is the default)!</p><p>Make sure to thoroughly test your app if you use compiled bindings!</p><h2>So what is the big deal?</h2><p>To illustrate the problem, I’ve written a small demo app!</p><p>Let’s start by checking the view models code:</p><pre><code class="language-csharp">public abstract class ViewModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

public class MainViewModel : ViewModelBase
{
    private CurrentTimeViewModel _currentTime;

    public CurrentTimeViewModel CurrentTime
    {
        get { return _currentTime; }
        set
        {
            _currentTime = value;
            OnPropertyChanged();
        }
    }
}

public class CurrentTimeViewModel : ViewModelBase
{
    private string _currentTimeTicks;

    public string CurrentTimeTicks
    {
        get { return _currentTimeTicks; }
        set
        {
            _currentTimeTicks = value;
            OnPropertyChanged();
        }
    }

    public CurrentTimeViewModel()
    {
        Update();
    }

    public void Update()
    {
        CurrentTimeTicks = DateTime.Now.Ticks.ToString();
    }
}
</code></pre><p>Our view model is composed of 3 classes:</p><ul><li><strong>ViewModelBase</strong> is just a standard implementation for the <code>INotifyPropertyChanged</code> interface, providing an <code>OnPropertyChanged</code> helper method to its inheritors.</li><li><strong>MainViewModel</strong> will be used as the main view model for our sample and has a single property, <code>CurrentTime</code>.</li><li><strong>CurrentTimeViewModel</strong> has a single <code>CurrentTimeTicks</code> property which will contain a string representing the current time in ticks; an <code>Update</code> helper method has also been added to this view model.</li></ul><p>Now let’s take a look at the MainPage view:</p><pre><code class="language-xml">&lt;Page x:Class=&quot;CompiledBindings2.MainPage&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:local=&quot;using:CompiledBindings2&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      mc:Ignorable=&quot;d&quot;&gt;

    &lt;Grid Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition /&gt;
            &lt;RowDefinition Height=&quot;Auto&quot; /&gt;
        &lt;/Grid.RowDefinitions&gt;

        &lt;StackPanel Margin=&quot;12&quot;&gt;
            &lt;TextBlock Style=&quot;{StaticResource CaptionTextBlockStyle}&quot; Text=&quot;Current Time Ticks (Binding)&quot; /&gt;
            &lt;TextBlock Style=&quot;{StaticResource BodyTextBlockStyle}&quot; Text=&quot;{Binding CurrentTime.CurrentTimeTicks}&quot; /&gt;

            &lt;TextBlock Style=&quot;{StaticResource CaptionTextBlockStyle}&quot; Text=&quot;Current Time Ticks (x:Bind)&quot; /&gt;
            &lt;TextBlock Style=&quot;{StaticResource BodyTextBlockStyle}&quot; Text=&quot;{x:Bind ViewModel.CurrentTime.CurrentTimeTicks, Mode=OneWay}&quot; /&gt;
        &lt;/StackPanel&gt;

        &lt;StackPanel Grid.Row=&quot;1&quot;&gt;
            &lt;Button HorizontalAlignment=&quot;Stretch&quot;
                    Click=&quot;CreateChildViewModelButton_OnClick&quot;
                    Content=&quot;Create CurrentTimeViewModel&quot; /&gt;
            &lt;Button HorizontalAlignment=&quot;Stretch&quot;
                    Click=&quot;UpdateCurrentTimeViewModelButton_OnClick&quot;
                    Content=&quot;Update CurrentTimeViewModel&quot; /&gt;
            &lt;Button HorizontalAlignment=&quot;Stretch&quot;
                    Click=&quot;DestroyCurrentTimeViewModelButton_OnClick&quot;
                    Content=&quot;Destroy CurrentTimeViewModel&quot; /&gt;
        &lt;/StackPanel&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre><p>The MainPage view is composed of the following:</p><ul><li>a TextBlock with its <code>Text</code> property binded to <code>CurrentTimeViewModel.CurrentTimeTicks</code>, using “classic” bindings</li><li>a TextBlock with its <code>Text</code> property binded to <code>CurrentTimeViewModel.CurrentTimeTicks</code>, using compiled bindings</li><li>a Button to create a new CurrentTimeViewModel instance</li><li>a Button to update the current CurrentTimeViewModel instance</li><li>a Button to destroy the current CurrentTimeViewModel instance</li></ul><p>Finally, here’s the code behind for the MainPage view:</p><pre><code class="language-csharp">public sealed partial class MainPage : Page
{
    private readonly MainViewModel _viewModel;

    public MainPage()
    {
        this.InitializeComponent();

        _viewModel = new MainViewModel();

        this.DataContext = _viewModel;
    }

    public MainViewModel ViewModel
    {
        get { return _viewModel; }
    }

    private void CreateChildViewModelButton_OnClick(object sender, RoutedEventArgs e)
    {
        _viewModel.CurrentTime = new CurrentTimeViewModel();
    }

    private void UpdateCurrentTimeViewModelButton_OnClick(object sender, RoutedEventArgs e)
    {
        if (_viewModel.CurrentTime != null)
        {
            _viewModel.CurrentTime.Update();
        }
    }

    private void DestroyCurrentTimeViewModelButton_OnClick(object sender, RoutedEventArgs e)
    {
        _viewModel.CurrentTime = null;
    }
}
</code></pre><p>As you can see above, we create a new MainViewModel instance, set it as the page <code>DataContext</code> property, and then we have the three click event handlers, one for each of the buttons on the view.</p><p>We’ve also added a <code>MainPage.ViewModel</code> property to expose the current MainViewModel instance to the compiled bindings (we can’t use the <code>DataContext</code> property as its type is <code>object</code> and compiled bindings require strong-typed properties to work).</p><p>This is what you’ll get if you run the app and tap the buttons in succession:</p><p><img src="/e57a014afdec56e238c850d410851899/Compiled-Bindings-FallbackValue-bug.gif" alt="Compiled Bindings FallbackValue bug"/></p><p>As you can see, the 2nd TextBlock (the one using compiled bindings) never gets the text cleared when we tap the “Destroy CurrentTimeViewModel” button!</p><p>The expected behavior is the one shown in the 1st TextBlock: if the binding value is <code>null</code> or unavailable, the <code>TextBlock.Text</code> property will set to the <a href="https://msdn.microsoft.com/en-US/library/windows/apps/xaml/windows.ui.xaml.data.binding.fallbackvalue">Binding.FallbackValue</a> (which is <code>null</code> by default).</p><p>So after checking the documentation for compiled bindings, one can say without that compiled bindings are ignoring the fallback value when its value is <code>null</code>, and that is quite <strong>a nasty bug in the compiled bindings!</strong></p><p>This bug has already been reported to Microsoft but as we don’t know when it will get fixed, all we can do right now is be aware of the whole issue and make sure to test our apps thoroughly to ensure we don’t end up with these problems after migrating to compiled bindings!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paying the tab for .NET Native]]></title>
            <link>https://www.pedrolamas.com/2015/12/08/paying-the-tab-for-dotnet-native/</link>
            <guid>https://www.pedrolamas.com/2015/12/08/paying-the-tab-for-dotnet-native/</guid>
            <pubDate>Tue, 08 Dec 2015 09:41:10 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/1c28d8732e6e362d5f2e252d790046d1/yoursign-459x510.jpg" alt="Paying the tab for .NET Native" class="webfeedsFeaturedVisual" /></p><blockquote><p>.NET Native behaves just like that expensive restaurant you love to got to: you have to wait until you finish the meal to see how much it will cost you - and it will definitely cost you!</p></blockquote><p>Last weekend I was confronted with a bug in <a href="http://cimbalino.org">Cimbalino Toolkit</a> <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit%20(WP8)/Behaviors/MultiBindingBehavior.cs">MultiBindingBehavior</a>, which caused apps using it to crash when they were built in Release mode!</p><p>I built a small test app and after a couple of minutes debugging it I noticed a <a href="https://msdn.microsoft.com/en-us/library/dn600633(v=vs.110).aspx">MissingMetadataException</a> getting raised; the culprit was found: .NET Native!</p><blockquote><p>If you’re working with Universal Windows Apps (<abbr title="Universal Windows Platform">UWP</abbr>) and don’t know what .NET Native is, I strongly advise you to start by reading the following excellent articles written by Morgan Brown, “a Software Development Engineer on the .NET Native team”:</p><ul><li><a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/20/net-native-deep-dive-dynamic-features-in-static-code.aspx">.NET Native Deep Dive: Dynamic Features in Static Code</a></li><li><a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/21/net-native-deep-dive-help-i-hit-a-missingmetadataexception.aspx">.NET Native Deep Dive: Help! I Hit a MissingMetadataException!</a></li><li><a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/22/net-native-deep-dive-help-i-didn-t-hit-a-missingmetadataexception.aspx">.NET Native Deep Dive: Help! I Didn’t Hit a MissingMetadataException!</a></li><li><a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/23/net-native-deep-dive-making-your-library-great.aspx">.NET Native Deep Dive: Making Your Library Great</a></li><li><a href="http://blogs.msdn.com/b/dotnet/archive/2014/05/24/net-native-deep-dive-optimizing-with-runtime-directives.aspx">.NET Native Deep Dive: Optimizing with Runtime Directives</a></li></ul></blockquote><p>Here’s the situation right now: when you build a <abbr title="Universal Windows Platform">UWP</abbr> app, the compiler will do some “smart stuff” with your code (let’s skip the technicals here!), squeezing every little bit it can to make sure the compiled result will perform better and faster!</p><p>But there is a catch: if your code uses any type of dynamic coding features such as reflection or serialization, you might need to instruct the compiler that certain types in your application will be used as such, in order to avoid the exceptions like the <code>MissingMetadataException</code> you see above.</p><p>To avoid such problems, you can add specially built <code>rd.xml</code> files to your project - once again, check the articles above for more information on this subject!</p><p>The <code>MultiBindingBehavior</code> works by using the <code>AssociateObject</code> property value to reflect and dynamically create a binding expression, so what I needed was to ensure that it would be able to reflect any object passed to this property.</p><p>With this requirement in mind, I created a new <code>Cimbalino.Toolkit.rd.xml</code> file, set its Build Action to Embedded Resource, and set the content to the following:</p><pre><code class="language-xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Directives xmlns=&quot;http://schemas.microsoft.com/netfx/2013/01/metadata&quot;&gt;
  &lt;Library Name=&quot;Cimbalino.Toolkit&quot;&gt;
    &lt;Type Name=&quot;Cimbalino.Toolkit.Behaviors.MultiBindingBehavior&quot;&gt;
      &lt;Property Name=&quot;AssociatedObject&quot; Serialize=&quot;Included&quot; /&gt;
    &lt;/Type&gt;
  &lt;/Library&gt;
&lt;/Directives&gt;
</code></pre><p>Aaand… this didn’t work! I started getting a build error message stating that it couldn’t find any <code>AssociatedObject</code> property in the <code>Cimbalino.Toolkit.Behaviors.MultiBindingBehavior</code>.</p><p>Granted, the property does not exist directly in this class, but rather in the <code>Behavior&lt;T&gt;</code> base class, so I guess one say that .NET Native compilation completely forgot a completely basic feature of .NET and most object oriented languages: <a href="https://en.wikipedia.org/wiki/Object-oriented_programming#Composition.2C_inheritance.2C_and_delegation">Class Inheritance</a>!</p><p>Taking this into account, I made a couple of changes in the file and here’s what in the end made it work:</p><pre><code class="language-xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Directives xmlns=&quot;http://schemas.microsoft.com/netfx/2013/01/metadata&quot;&gt;
  &lt;Library Name=&quot;Cimbalino.Toolkit&quot; /&gt;
  &lt;Library Name=&quot;Microsoft.Xaml.Interactions&quot;&gt;
    &lt;Type Name=&quot;Microsoft.Xaml.Interactivity.Behavior{T}&quot;&gt;
      &lt;Property Name=&quot;AssociatedObject&quot; Serialize=&quot;Included&quot; /&gt;
    &lt;/Type&gt;
  &lt;/Library&gt;
&lt;/Directives&gt;
</code></pre><p>So here’s what I learned in the past weekend:</p><ul><li>When working with Universal Windows Apps, <strong>make sure to build the app in Release mode and test it thoroughly!</strong></li><li>Keep an eye out on the build warnings for any problems with your <code>rd.xml</code> files.</li><li>If you’re working with <abbr title="Model View ViewModel">MVVM</abbr> or have Model representation classes, it might make sense to put these in a separate assembly, or at least in a separate namespace from the rest of the code - this will allow you to easily target these files in a <code>rd.xml</code> for .NET Native optimization exclusion.</li></ul>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XAML Behaviors now open source and on UWP]]></title>
            <link>https://www.pedrolamas.com/2015/12/02/xaml-behaviors-now-open-source-and-on-uwp/</link>
            <guid>https://www.pedrolamas.com/2015/12/02/xaml-behaviors-now-open-source-and-on-uwp/</guid>
            <pubDate>Wed, 02 Dec 2015 09:49:35 GMT</pubDate>
            <content:encoded><![CDATA[<p>In case you missed the <a href="https://blogs.windows.com/buildingapps/2015/11/30/xaml-behaviors-open-source-and-on-uwp/">big news</a>, the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors are now <a href="https://github.com/Microsoft/XamlBehaviors/">open source in GitHub</a> and available to use in <abbr title="Universal Windows Platform">UWP</abbr>, both in <a href="https://www.nuget.org/packages/Microsoft.Xaml.Behaviors.Uwp.Managed/">managed</a> and <a href="https://www.nuget.org/packages/Microsoft.Xaml.Behaviors.Uwp.Native/">native</a> apps, mostly due to the work of some <a href="https://github.com/Microsoft/XamlBehaviors/wiki/About-the-Team#our-team-of-mvp-leaders-includes">awesome MVPs</a>!</p><p>They were kind enough to keep me in the loop and that allowed me to prepare for the incoming changes! ;)</p><h2>Cimbalino Toolkit 2.1.0</h2><p><strong>Version 2.1.0</strong> of the <a href="http://cimbalino.org/">Cimbalino Toolkit</a> is a basic update of the toolkit with a few improvements and bug fixes, but takes into account the new <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors:</p><ul><li><abbr title="Universal Windows Platform">UWP</abbr> apps it now will pull the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors Managed NuGet package to the projects</li><li>non-<abbr title="Universal Windows Platform">UWP</abbr> apps will still use the NuGet PowerShell scripts to add the Behaviors <abbr title="Software Development Kit">SDK</abbr></li></ul><p>A few weeks ago I introduced the <code>MonitoredInteraction</code> class from Cimbalino Toolkit 2.0.0 to <a href="/2015/10/23/how-to-prevent-memory-leaks-in-behaviors/">“prevent memory leaks in behaviors”</a>, and I’m happy to say that those changes <a href="https://github.com/Microsoft/XamlBehaviors/commit/c23f4a4156318042eaf651faea8f2fafd9467d59">made it’s way to the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors code</a>! :)</p><p>Do notice that while the <code>Interaction</code> class in the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviors now performs the proper attach/detach pattern, the same can’t be said for the Behaviors <abbr title="Software Development Kit">SDK</abbr> Extension for non-<abbr title="Universal Windows Platform">UWP</abbr> apps, so I strongly advise you to keep using the <code>MonitoredInteraction</code> class for those projects!</p><p>One final note: if you actually want to <strong>use</strong> the <abbr title="Extensible Application Markup Language">XAML</abbr> Behaviours, you will have to actually manually add the NuGet package to your project… this is due to the new Transitive Dependencies feature of NuGet 3.x, and as far as I know, there is no way of going around this extra step!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CultureInfo changes in UWP]]></title>
            <link>https://www.pedrolamas.com/2015/11/02/cultureinfo-changes-in-uwp/</link>
            <guid>https://www.pedrolamas.com/2015/11/02/cultureinfo-changes-in-uwp/</guid>
            <pubDate>Mon, 02 Nov 2015 16:32:32 GMT</pubDate>
            <content:encoded><![CDATA[<p><strong>Update:</strong> There’s now a <a href="/2017/05/03/cultureinfo-changes-in-uwp-part-2/">part 2</a> for this article!</p><p>Since the very first versions of the .NET Framework, developers had the <a href="https://msdn.microsoft.com/en-us/library/system.globalization(v=vs.110).aspx">System.Globalization</a> namespace <em>“containing classes that define culture-related information, including language, country/region, calendars in use, format patterns for dates, currency, and numbers, and sort order for strings.”</em></p><p>One of the most useful classes in this namespace is the <a href="https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=vs.110).aspx">CultureInfo</a> class!</p><p>To demonstrate the usage of this class, take a look at this really simple console app code:</p><pre><code class="language-csharp">using System;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(&quot;CurrentCulture: {0}&quot;, CultureInfo.CurrentCulture);
        Console.WriteLine(&quot;CurrentUICulture: {0}&quot;, CultureInfo.CurrentUICulture);
    }
}
</code></pre><p>If you run the above code with different system configurations, this is what it would output:</p><pre><code class="language-text">// Display Language = &quot;English (US)&quot;, Location = &quot;United States&quot;, Regional Settings = &quot;English (US)&quot;
CurrentCulture: en-US
CurrentUICulture: en-US

// Display Language = &quot;English (US)&quot;, Location = &quot;United States&quot;, Regional Settings = &quot;Portuguese (Portugal)&quot;
CurrentCulture: pt-PT
CurrentUICulture: en-US

// Display Language = &quot;English (United Kingdom)&quot;, Location = &quot;Spain&quot;, Regional Settings = &quot;Portuguese (Angola)&quot;
CurrentCulture: pt-AO
CurrentUICulture: en-GB
</code></pre><p>As you can see from the above results, the <code>CurrentCulture</code> and <code>CurrentUICulture</code> property values are inferred respectively from Regional Settings and Display Language; the Location however, doesn’t seem to have any effect over these two properties.</p><p>This feature allowed any app to show data using the proper currency, date, and number formats, even if the app itself wasn’t localized for those cultures!</p><p>But then came WinRT with the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.globalization.aspx">Windows.Globalization</a> namespace as a replacement, and that apparently affected the way the <code>CultureInfo</code> class behaved…</p><p>To show the differences, I’ve created a blank Windows 8 app, and set the following code in the MainView.xaml.cs file:</p><pre><code class="language-csharp">using System;
using System.Globalization;
using Windows.UI.Popups;
using Windows.UI.Xaml.Controls;

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();

        this.Loaded += MainPage_Loaded;
    }

    private void MainPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    {
        var messageDialog = new MessageDialog(string.Format(&quot;CurrentCulture: {0}&quot; + Environment.NewLine + &quot;CurrentUICulture: {1}&quot;,
            CultureInfo.CurrentUICulture,
            CultureInfo.CurrentCulture));

        messageDialog.ShowAsync();
    }
}
</code></pre><p>These are the results of running the above code:</p><pre><code class="language-text">// Display Language = &quot;English (US)&quot;, Location = &quot;United States&quot;, Regional Settings = &quot;English (US)&quot;
CurrentCulture: en-US
CurrentUICulture: en-US

// Display Language = &quot;English (US)&quot;, Location = &quot;United States&quot;, Regional Settings = &quot;Portuguese (Portugal)&quot;
CurrentCulture: en-US
CurrentUICulture: en-US

// Display Language = &quot;English (United Kingdom)&quot;, Location = &quot;Spain&quot;, Regional Settings = &quot;Portuguese (Angola)&quot;
CurrentCulture: en-GB
CurrentUICulture: en-GB
</code></pre><p>As you can see here, both the <code>CurrentCulture</code> and <code>CurrentUICulture</code> property values are now based on the selected Display Language!</p><p>In my personal opinion, this change of behavior is wrong for various reasons, but mostly because it breaks the expected known behavior of the <code>CultureInfo</code> class properties.</p><p>Right now you might be thinking that the impact of this change is really small, but it might actually be bigger than expect due to a specific feature: <strong>Cortana!</strong></p><p>As of today, Cortana is still only available in a few locations, and as such, most users have “faked” their location in order to get Cortana active on their devices, but maintained the Regional Settings matching their real location!</p><h2>Retrieving the “proper” CurrentCulture</h2><p>One could use the Windows <abbr title="Application Programming Interface">API</abbr> <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd318136.aspx">GetUserDefaultLocaleName</a> to retrieve the Regional Settings, but this only works on full Windows 10, so it’s not a “universal” way of doing it!</p><p>However, I’ve found that if you create a <a href="https://msdn.microsoft.com/en-us/library/windows/apps/windows.globalization.datetimeformatting.datetimeformatter">DateTimeFormatter</a> instance with “US” as language, you can retrieve the culture name from the <code>DateTimeFormatter.ResolvedLanguage</code> property!</p><p>And here is a simple code example demonstrating how to do it:</p><pre><code class="language-csharp">using Windows.Globalization.DateTimeFormatting;

public class CultureInfoHelper
{
    public static CultureInfo GetCurrentCulture()
    {
        var cultureName = new DateTimeFormatter(&quot;longdate&quot;, new[] { &quot;US&quot; }).ResolvedLanguage;

        return new CultureInfo(cultureName);
    }
}
</code></pre><p>I honestly still don’t know how or why does this work with that <em>Magic String™</em> (others might also do the trick though), but it does, and at this stage all I care are positive results!</p><p>So there you go, this is a nice hack to retrieve a <code>CultureInfo</code> instance for the Regional Settings, which you can then use to parse and format values in your <abbr title="Universal Windows Platform">UWP</abbr> (and WinRT) app! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to prevent memory leaks in Behaviors]]></title>
            <link>https://www.pedrolamas.com/2015/10/23/how-to-prevent-memory-leaks-in-behaviors/</link>
            <guid>https://www.pedrolamas.com/2015/10/23/how-to-prevent-memory-leaks-in-behaviors/</guid>
            <pubDate>Fri, 23 Oct 2015 18:01:33 GMT</pubDate>
            <content:encoded><![CDATA[<p>Attached Behaviors have been around for quite a while, and though I personally always liked them, they have a fundamental flaw: they can lead to huge memory leaks!</p><p>I’ve seen quite a few fixes for them (like <a href="http://dotnetbyexample.blogspot.co.uk/2011/04/safe-event-detachment-pattern-for.html">this one</a> from <abbr title="Most Valuable Professional">MVP</abbr> Joost Van Schaik), though none proved to be truly “universal” and final!</p><p>To demonstrate the problem, let’s take a practical example:</p><ul><li>create an app with two pages</li><li>page 1 will have a button to navigate to page 2</li><li>page 2 will have a button that when clicked, will navigate back to page 1 after a pause of 2 seconds</li></ul><p>Here’s the view model for page 2, <code>Page2ViewModel</code>:</p><pre><code class="language-csharp">public class Page2ViewModel
{
    public event EventHandler GoBack;

    public ICommand DelayedGoBackCommand { get; private set; }

    public MainViewModel()
    {
        DelayedGoBackCommand = new CustomCommand(OnDelayedGoBackCommand);
    }

    private async void OnDelayedGoBackCommand()
    {
        await Task.Delay(2000);

        GoBack?.Invoke(this, EventArgs.Empty);
    }
}
</code></pre><p>The code is really simple: when the <code>DelayedGoBackCommand</code> gets invoked, we will make a 2 seconds pause, and then raise the <code>GoBack</code> event.</p><p>Now lets say that all view models have been registered as singletons in the <code>App</code> class, something like this:</p><pre><code class="language-csharp">sealed partial class App : Application
{
    public static Page2ViewModel Page2ViewModel { get; } = new Page2ViewModel();

    // remaining code
}
</code></pre><p>This is the code behind for page 2, where we will set the page view model:</p><pre><code class="language-csharp">public class Page2
{
    public Page2()
    {
        InitializeComponent();

        DataContext = App.Page2ViewModel;
    }
}
</code></pre><p>And this is the view we will be using for page 2:</p><pre><code class="language-xml">&lt;Page x:Class=&quot;MyApp.Page2&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:core=&quot;using:Microsoft.Xaml.Interactions.Core&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:i=&quot;using:Microsoft.Xaml.Interactivity&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      x:Name=&quot;PageRoot&quot;
      mc:Ignorable=&quot;d&quot;&gt;

    &lt;StackPanel Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
        &lt;i:Interaction.Behaviors&gt;
            &lt;core:EventTriggerBehavior EventName=&quot;GoBack&quot;
                                       SourceObject=&quot;{Binding}&quot;&gt;
                &lt;core:CallMethodAction MethodName=&quot;GoBack&quot;
                                       TargetObject=&quot;{Binding Frame,
                                                              ElementName=PageRoot}&quot; /&gt;
            &lt;/core:EventTriggerBehavior&gt;
        &lt;/i:Interaction.Behaviors&gt;

        &lt;Button Command=&quot;{Binding DelayedGoBackCommand,
                                  Mode=OneTime}&quot;
                Content=&quot;Go Back&quot; /&gt;
    &lt;/StackPanel&gt;
&lt;/Page&gt;
</code></pre><p>As you can see above, the button is binded to the <code>Page2ViewModel.DelayedGoBackCommand</code>. Also, we will be using an <code>EventTriggerBehavior</code> to monitor the <code>Page2ViewModel.GoBack</code> event, and when it gets raised, we will use the <code>CallMethodAction</code> to invoke the <code>Page2.Frame.GoBack</code> method.</p><p>Now here’s the catch: <strong>while behaviors have a way of being notified when they are to be detached, that never happens!!</strong> Not when you leave the page, not when the page gets unloaded, and not even when garbage collection runs.</p><p>As such, when we navigate back from page 2, <code>Page2ViewModel.GoBack</code> event will still hold a reference to the <code>EventTriggerBehavior</code>, leading to a memory leak!</p><p>But things get even worse in this example: everytime we navigate to page 2, we will subscribe over and over again the <code>GoBack</code> event, so multiple invocations will eventually occur - definitely not what we wanted!</p><h2>Introducing the MonitoredInteraction class</h2><p>The <a href="http://cimbalino.org">Cimbalino Toolkit</a> now has the <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit%20(WP8)/Behaviors/MonitoredInteraction.cs"><strong>MonitoredInteraction</strong></a> class to solve this issue!</p><p>The <code>MonitoredInteraction</code> was built as a direct replacement of the <code>Microsoft.Xaml.Interactivity.Interaction</code>, and will monitor the attached object <code>Loaded</code> and <code>Unloaded</code> events and call for the attachment and detachment of all behaviors it contains!</p><p>Here’s how page 2 view would look if put it to use:</p><pre><code class="language-xml">&lt;Page x:Class=&quot;MyApp.Page2&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:core=&quot;using:Microsoft.Xaml.Interactions.Core&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      xmlns:behaviors=&quot;using:Cimbalino.Toolkit.Behaviors&quot;
      x:Name=&quot;PageRoot&quot;
      mc:Ignorable=&quot;d&quot;&gt;

    &lt;StackPanel Background=&quot;{ThemeResource ApplicationPageBackgroundThemeBrush}&quot;&gt;
        &lt;behaviors:MonitoredInteraction.Behaviors&gt;
            &lt;core:EventTriggerBehavior EventName=&quot;GoBack&quot;
                                       SourceObject=&quot;{Binding}&quot;&gt;
                &lt;core:CallMethodAction MethodName=&quot;GoBack&quot;
                                       TargetObject=&quot;{Binding Frame,
                                                              ElementName=PageRoot}&quot; /&gt;
            &lt;/core:EventTriggerBehavior&gt;
        &lt;/behaviors:MonitoredInteraction.Behaviors&gt;

        &lt;Button Command=&quot;{Binding DelayedGoBackCommand,
                                  Mode=OneTime}&quot;
                Content=&quot;Go Back&quot; /&gt;
    &lt;/StackPanel&gt;
&lt;/Page&gt;
</code></pre><p>Really, really simple, yet it will finally ensure that behaviors do get detached when one navigates away of a page, and re-attached when navigating in!</p><p>Hopefully someone from the Behaviors <abbr title="Software Development Kit">SDK</abbr> team will read this, and take some of the suggestions here to fix this well known issue that’s been around for quite a while! ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiled Bindings considerations]]></title>
            <link>https://www.pedrolamas.com/2015/10/19/compiled-bindings-considerations/</link>
            <guid>https://www.pedrolamas.com/2015/10/19/compiled-bindings-considerations/</guid>
            <pubDate>Mon, 19 Oct 2015 11:45:09 GMT</pubDate>
            <content:encoded><![CDATA[<p>As you’re probably aware, Windows 10 introduced a new type of Bindings called <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt204783.aspx"><strong>Compiled Bindings</strong></a>.</p><p>And as the name might suggest, compiled bindings are a way the compiler uses to generate static code for a binding instead of using a reflection based solution, as regular bindings do.</p><p>The main advantage is quite obvious: there will be a performance gain for using static compiled code instead of using reflection!</p><p>Let’s take a look at a simple regular binding example:</p><pre><code class="language-xml">&lt;TextBlock Text=&quot;{Binding Name}&quot; /&gt;
</code></pre><p>This binding will set the <code>TextBlock.Text</code> property to the value of the <code>Name</code> and will update it every time the <code>Name</code> property changes (assuming that the data context implements and raises the necessary <code>INotifyPropertyChanged.PropertyChanged</code> event)</p><p>To take advantage of the compiled bindings, one would rewrite it like this:</p><pre><code class="language-xml">&lt;TextBlock Text=&quot;{x:Bind Name, Mode=OneWay}&quot; /&gt;
</code></pre><p>Notice that I added the <code>Mode=OneWay</code> on the expression above?</p><p>Well, that is actually required due to a fundamental difference between regular bindings and compiled bindings: while the regular bindings default mode is <code>OneWay</code>, <strong>compiled bindings default mode is <code>OneTime</code>!</strong></p><p>This is a really important piece of information that I’ve seen a lot of developers not taking notice, so make sure to fix those binding expressions correctly when you migrate to compiled bindings!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit 2.0.0 (final)]]></title>
            <link>https://www.pedrolamas.com/2015/10/09/cimbalino-toolkit-2-0-0-final/</link>
            <guid>https://www.pedrolamas.com/2015/10/09/cimbalino-toolkit-2-0-0-final/</guid>
            <pubDate>Fri, 09 Oct 2015 19:12:14 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit 2.0.0 (final)" class="webfeedsFeaturedVisual" /></p><p>Bring out the champagne, because <a href="http://cimbalino.org/"><strong>Cimbalino Toolkit</strong></a> version 2.0.0 has gone “gold” and is now production ready! :)</p><p>As <a href="/2015/07/31/cimbalino-toolkit-2-0-0-beta1/">previously stated</a>, the focus for this new version was to add support for <abbr title="Universal Windows Platform">UWP</abbr> (Universal Windows Platform), thus making the toolkit support a total of 4 platforms:</p><ul><li>Windows Phone Silverlight 8.0 and 8.1 apps (<abbr title="Windows Phone 8">WP8</abbr>)</li><li>Windows Phone 8.1 apps (WPA81)</li><li>Windows Store 8.1 apps (Win81)</li><li>Windows 10 <abbr title="Universal Windows Platform">UWP</abbr> apps (Universal Windows Platform)</li></ul><p>Please remember to manually add the Behaviors <abbr title="Software Development Kit">SDK</abbr> to your <abbr title="Universal Windows Platform">UWP</abbr> apps if you use Cimbalino! The other platforms will have it added automatically, but due to changes in the way NuGet works this is not possible for <abbr title="Universal Windows Platform">UWP</abbr>.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit 2.0.0-beta1]]></title>
            <link>https://www.pedrolamas.com/2015/07/31/cimbalino-toolkit-2-0-0-beta1/</link>
            <guid>https://www.pedrolamas.com/2015/07/31/cimbalino-toolkit-2-0-0-beta1/</guid>
            <pubDate>Fri, 31 Jul 2015 10:46:21 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit 2.0.0-beta1" class="webfeedsFeaturedVisual" /></p><p>Assuming you don’t live in a planet where you don’t get internet (and I know that’s not the case as you’re reading this!), by now you know that <strong>Windows 10 has officially launched</strong>!</p><p>So did Visual Studio 2015 and NuGet 3.x, so pretty much everything you need to develop new Windows 10 universal apps, right? Not quite! ;)</p><p>Presenting the new and improved version 2.0.0-beta1 of the <a href="http://cimbalino.org"><strong>Cimbalino Toolkit</strong></a>, and as you already suspect, it is fully compatible with <abbr title="Universal Windows Platform">UWP</abbr> (Universal Windows Platform)!</p><p>Proper <a href="https://en.wikipedia.org/wiki/Kudos">kudos</a> is owed to <abbr title="Most Valuable Professional">MVP</abbr> <a href="https://twitter.com/scottisafool">Scott Lovegrove</a> as he has done pretty good job for the last couple of weeks to get the toolkit up and running in Windows 10! :)</p><p>There is a breaking change on using the toolkit from previous versions: NuGet has removed the functionality of running Powershell scripts when you install a package, and Cimbalino Toolkit required that to add the Behaviors <abbr title="Software Development Kit">SDK</abbr> to your projects… that said, please make sure that you manually add the Behaviors <abbr title="Software Development Kit">SDK</abbr> to any project using the <code>Cimbalino.Toolkit</code> NuGet package!</p><p>On a final now, remember that this new version is still a beta as the code and documentation will be reviewed and tested during the next weeks, so do expect to find some issues and bugs! If you find any, please do report them directly on <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/issues">GitHub</a>!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[There's never been a better time to be a Microsoft developer!]]></title>
            <link>https://www.pedrolamas.com/2015/05/05/theres-never-been-a-better-time-to-be-a-microsoft-developer/</link>
            <guid>https://www.pedrolamas.com/2015/05/05/theres-never-been-a-better-time-to-be-a-microsoft-developer/</guid>
            <pubDate>Tue, 05 May 2015 11:54:25 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/c65caebddf8e3a7b6d09d15e33f1a47b/Microsoft-Build.png" alt="There's never been a better time to be a Microsoft developer!" class="webfeedsFeaturedVisual" /></p><p><em>Full disclosure: though <a href="/2014/12/12/bye-mixradio/">I’ve been a Microsoft employee for a short while</a>, I currently have no professional (or other type of) connection with the company.</em></p><p>Now that we have got that out of the way, I do believe that there has never been a better time to be a Microsoft developer than today! :)</p><h2>Ok, I’ll bite… why do you think that?</h2><p><a href="http://www.buildwindows.com/">Microsoft Build Developers Conference</a> was held last week in San Francisco. On it, Microsoft showed it’s vision for the future, and it is a bright one!</p><p>Though this article only scratches the surface on all that was shown, these were my personal highlights of the event!</p><h2>Windows 10 everywhere!</h2><p>Yes, Windows 10 will be everywhere, from PC’s, Laptops and Tablets, the Xbox One and Hololens, and also powering IoT devices like the Raspberry Pi 2.</p><p>For developers this translates in the fact that apps you develop for Windows 10, will also run in any other device! Functionality may obviously differ from device to device given their capabilities (touch screen on a tablet, augmented reality in Hololens, sensors on IoT devices, etc.), but in the end it will be the same Windows 10 app running on all of them!</p><h2>Open-source initiative</h2><p>The amount of code made available over the last couple of weeks in <a href="http://microsoft.github.io/">Microsoft’s GitHub page</a> is truly astonishing!</p><p>Microsoft went from a closed-source software company to open-source a big chunk of their code in order to get contributions from the community (comments, reviews, code contributions, etc.), just like in any other GitHub repository!</p><h2>Going cross-platform</h2><p>Say goodbye to the Microsoft you’ve know for years as a Windows and Office only company; <em>“Mobile first, cloud first”</em> is the new motto, and there was enough proof of that in Build conference.</p><p>If you’re a web developer, you should definitely give <a href="https://code.visualstudio.com//">Visual Studio Code</a> a spin - and here’s the twist: it runs not only in Windows, but also in Mac and Linux, as Visual Studio Code is itself built on top of open-source technologies!</p><p>The whole CoreCLR (.NET Core Runtime) was built for Windows but now runs in Mac and Linux machines, meaning you can run the same .NET based code in all these platforms!</p><h2>iOS and Android apps are welcome!</h2><p>Develop apps for iOS or Android? Well, there’s some good news for you too: with Project Islandwood and Project Astoria, you’ll be able to make those apps run in Windows 10 with just a few modifications, and even sell them through the Windows Store and make some money out of it!</p><p>Targeting the Windows platform is definitely a smart move, as it will enable you to reach more users and increase potential revenue from your apps.</p><h2>All apps are now Windows Apps</h2><p>The “older” .NET and Win32 desktop apps we use all day long will now have a place in the Windows Store, making life easier for users to find, download and use them!</p><p>Just package those apps as a Windows 10 app, ship it to the store, and you’re done!</p><h2>One more thing</h2><p>Hololens! If you don’t know what it is by now, then you definitely should!!</p><p>While other companies are investing Virtual Reality, Microsoft took a different approach with Hololens and went with Augmented Reality.</p><p>As the name might suggest, “Augmented Reality” adds information to your <em>real</em> environment, and it’s usages are quite diverse. Microsoft showed a couple of demos of usage for construction and health that I believe made some jaw’s drop!</p><h2>“DEVELOPERS, DEVELOPERS, DEVELOPERS!!”</h2><p>No one said it, but I’m sure a lot of people remembered this while watching Build 2015:</p><p><a href="https://www.youtube.com/watch?v=Vhh_GeBPOhs">https://www.youtube.com/watch?v=Vhh_GeBPOhs</a></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit Documentation]]></title>
            <link>https://www.pedrolamas.com/2015/04/24/cimbalino-toolkit-documentation/</link>
            <guid>https://www.pedrolamas.com/2015/04/24/cimbalino-toolkit-documentation/</guid>
            <pubDate>Fri, 24 Apr 2015 14:28:36 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit Documentation" class="webfeedsFeaturedVisual" /></p><p>The biggest request (and at the same time, the biggest complaint) I always had about <a href="http://cimbalino.org">Cimbalino Toolkit</a> was to get some proper documentation about what the toolkit actually contains!</p><p>That has now changed, as the documentation is live at <a href="http://cimbalino.org/help">http://cimbalino.org/help</a></p><p><a href="http://cimbalino.org/help"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:57.77777777777777%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABZElEQVQoz4WQy07CQBSGeR6fxI1b405jJC0XF0KivoNrdyZuWPISJlDC0rhEEAjTznRop9NOp7e5mCJRIVW+1flz8uX8ObXbu/ubTscwDNM0G6Z5dn51fHpxWTeu2+1ms9VuldTr9W63OxgMRqORZVnD4XA8Hvd6vdps4aygp5RWSmutG/3Z0cPbkwV0zmgY0ZDyhGutlVLZLlLKmk/jkCXlunS12Z+ePE8eXxZZ6DkQQeiQINB/UNvLK0xf55hEXAmRZlmaZkmSxGwL59sxYnF5eU8m3trDKGYxpWEYhsUOQoiiENuglNqXszx3EXIcCCECYIXXmHPOGFNfL/m/NufcBsBxHLsERBut0qyQCfGXyyUA9nT2AZGrtZZSSiE3jX/aCyEqZCEkiXIc5JQVhASui1yMEUK+57FfcJ5UyBi775MJAEApuUF9c7g2dPF8ZZOACqn0IfZln6YBK5JMppk4KH8Cld2a7eXHIn4AAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Cimbalino Toolkit Documentation" title="Cimbalino Toolkit Documentation" src="/static/2a1702ce5c2e2684894bf798d0bec786/37523/Cimbalino-Toolkit-Documentation.png" srcSet="/static/2a1702ce5c2e2684894bf798d0bec786/e9ff0/Cimbalino-Toolkit-Documentation.png 180w,/static/2a1702ce5c2e2684894bf798d0bec786/f21e7/Cimbalino-Toolkit-Documentation.png 360w,/static/2a1702ce5c2e2684894bf798d0bec786/37523/Cimbalino-Toolkit-Documentation.png 720w,/static/2a1702ce5c2e2684894bf798d0bec786/d6a46/Cimbalino-Toolkit-Documentation.png 1008w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>The whole documentation was generated from the inline <abbr title="Extensible Markup Language">XML</abbr> Documentation with the help of <a href="https://sandcastle.codeplex.com/">SandCastle</a>, so it’s still a bit minimum but I expect it to improve along time!</p><p>Please feel free to check it out and send some comments! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows 10 Technical Preview Tools now available!]]></title>
            <link>https://www.pedrolamas.com/2015/04/02/windows-10-technical-preview-tools-now-available/</link>
            <guid>https://www.pedrolamas.com/2015/04/02/windows-10-technical-preview-tools-now-available/</guid>
            <pubDate>Thu, 02 Apr 2015 15:24:25 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/a42c038dd707872c526eae08cfae58cc/Windows-10.png" alt="Windows 10 Technical Preview Tools now available!" class="webfeedsFeaturedVisual" /></p><p>In case you’ve missed it, Microsoft has now released the <a href="http://dev.windows.com/en-US/windows-10-developer-preview-tools">Windows 10 Technical Preview Developer Tools</a>!</p><p>These allow you to start using the Windows 10 Universal Apps Platform (<abbr title="Universal Apps Platform">UAP</abbr>) and thus developing apps for the next generation of Windows!</p><p>All you need is a machine (or <abbr title="Virtual Machine">VM</abbr>) with the latest Windows 10 Preview and Visual Studio <abbr title="Community Technology Preview">CTP</abbr> 6 to install the developer tools preview and start building some awesome apps!! :)</p><h2>Cimbalino Toolkit Windows 10 <abbr title="Universal Apps Platform">UAP</abbr> support</h2><p>I’ve been getting a lot of questions lately about Cimbalino Toolkit support for Windows 10 Apps (aka Universal Apps, <abbr title="Universal Apps Platform">UAP</abbr>, Windows Apps, etc…)</p><p>I can assure you that <strong>support is definitely coming</strong> and you can get an early look on what is being done in <a href="https://twitter.com/scottisafool">Scott Lovegroove’s</a> fork available <a href="https://github.com/ScottIsAFool/Cimbalino-Toolkit/tree/Win10UAP">here</a>!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit: Integrating with MVVM Light Toolkit]]></title>
            <link>https://www.pedrolamas.com/2015/01/26/cimbalino-toolkit-integrating-with-mvvm-light-toolkit/</link>
            <guid>https://www.pedrolamas.com/2015/01/26/cimbalino-toolkit-integrating-with-mvvm-light-toolkit/</guid>
            <pubDate>Mon, 26 Jan 2015 13:49:44 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit: Integrating with MVVM Light Toolkit" class="webfeedsFeaturedVisual" /></p><p>Picking up where we left off on the <a href="/2015/01/05/cimbalino-toolkit-step-by-step/">previous article</a>, you now know how to install the <a href="http://cimbalino.org">Cimbalino Toolkit</a> in your app, so congratulations for that! :)</p><p>On this article I will show how to integrate it with the <a href="http://mvvmlight.codeplex.com/"><abbr title="Model View ViewModel">MVVM</abbr> Light Toolkit</a>, and then build a really simple “Hello World” app!</p><p><strong>Note:</strong> Though this article will focus on how to integrate with the <abbr title="Model View ViewModel">MVVM</abbr> Light Toolkit, the Cimbalino Toolkit can be combined with most Windows development toolkits and frameworks that are available (like MVVMCross, Caliburn, etc.)</p><p>Using the same approach to add NuGet packages to the solution shown in the previous article, now search for “MvvmLight” and select the package shown in this picture:</p><p><a href="/719bdce70632ef2e08d73e415826d810/Searching-for-MVVM-Light-Toolkit.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:66.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAChElEQVQoz13Py2oUQRQG4H6MiJFgcDKX7uqu6qrqe1f1TFf1dS7dmaBJ1CSCG1cSRYKCaBizSCQXUDT4DvoCgiK4UZ8g7sSdTyEzEgjCWZzD4eP8R3m7VZ9sLp9s1gdr/YPV8vhGfDjmu31vMvAno2CvCnf77vO+vzdix7erV1srR7eqo436YHX05nql1GlGgx62Qx07OgnQ/ffJ/o908sl99pXvffMn362nX+4dflh/ckp54XVzZIfUZdBhdZoow4j5AccmNXRoQGo++pid/ll+9zt//at3eBa+/Onun4mjs/zF57Q/lvnIDzjFtNUBN/NEqeNeXlZhwAGAmqZrSw0XY4sgAsHiwvzC5bmrVy7NX5rrtJp5VhblyAsijMhSG6zniVKGPjCwpukAQADgUkvzPF9IGUVd1/WQaRJCTdMkGONANt2iCV1NBY3WDCeO1eroug5n2JjhQAjJGGchsyzbojYhFGMcJ2XWrxnrsjDSEV3LpJK6dls1dHCOm5rvhUKIKebRFFvWP5wm2XBQVdV4uR6HkVjLxH8YLjYWPd9zbNc0sYmmmSm1ZsmxlPloWJflcDSsiOXVEbuIkaYC7MQsEmEYzq4RggkhlBCKkOn7LEuLohgM+kPbY8tdrkiHNttA03RVM1QVQNpjXHDOKbUc27Esx6I2pRbGxIBYyFSIJI4TN4jGvUhZSRMeyW43jnvSdfxrjRbnUVGUWZpnWVbkhRDScRyEsOezwbCKe5IFXEek4qGyWuQyLaVI/IBhbDWWWu22qqqgo2oA6KoGOh3tfISM92SSpUlGnWD68/adjQfbDz3b1VWADGQaCOkQAmNaOoQXejRbgY7GvGBn5/HO3a2/kjLI7T+JogEAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Searching for MVVM Light Toolkit" title="Searching for MVVM Light Toolkit" src="/static/719bdce70632ef2e08d73e415826d810/37523/Searching-for-MVVM-Light-Toolkit.png" srcSet="/static/719bdce70632ef2e08d73e415826d810/e9ff0/Searching-for-MVVM-Light-Toolkit.png 180w,/static/719bdce70632ef2e08d73e415826d810/f21e7/Searching-for-MVVM-Light-Toolkit.png 360w,/static/719bdce70632ef2e08d73e415826d810/37523/Searching-for-MVVM-Light-Toolkit.png 720w,/static/719bdce70632ef2e08d73e415826d810/1cfc2/Searching-for-MVVM-Light-Toolkit.png 900w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>You should now click on the <em>Install</em> button, confirm that you want to install the package into both projects, review the details shown in the <em>License Acceptance</em> window, and click the <em>I Accept</em> button.</p><p>You will now see a couple of warnings about moving the <em>ViewModel</em> folder manually; this is expected and it is due to the fact that we are building a Universal App (you can find more information about this <a href="http://www.mvvmlight.net/nuget-univ">here</a>).</p><p>Look at the Solution Explorer Window, you should see that we have two <em>ViewModel</em> folders, one on each of the projects:</p><p><a href="/46494e2bca0342af9a06e0f3cda0f7cd/Projects-with-different-ViewModel-folders.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:430px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:117.77777777777779%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAC5UlEQVQ4y42T3Y7cNBTHc8fXAxSk0jKTxI6dLztxkhnny7ETO7PsajsI6F1BSFwiYBeWYWGhlbjmEXgEQJ0rVmKXR0PDVFy02W2Pfhe++fkc/49s2Y+vZz9fz3+6cp78c+f8b/vx9Vunl6+d/PX6yeUbp9O8eXp59+Lq7sWVxXKeZlyosWxU1fZKH1ZiaKTJlm1A8pvAUYbjzOLFYpll9aLgjHHGypzllC5ZmgQ4CdAkFEOekpUUlv78F/P1b/35Vm7+ND9u1flT/cPT1cW2OPkj+Woa+uXv+Tfb5dnWyg4/Gx+dHH3xa/XoCfvoW/rhJv/4rHi4CT7YeA++w+vvJ0EPNuj4zPJcmwVu06QrLTqej6qucqoabsRSVlmZBuD+O867d17Evfe25boQB1GcpEofaD0eHa/rRmA/DGMaRgTh0IVoEuBhy3UBQpgSorp66HVTN4QQx3H3uC4AAAIAXRc8BwBwJ3vIzxLy6ZoL0VVlhRG2bcfelWPbzny+O0zL+1vjKHq4PpCyH82otaE0ybI8z4ssKxbFgsR0P8VEZwi9KCaVGMxglOql7DvRkZgkCUtowhgLgnBaBgDathOFkTk8Fq3Q2mhtuq5rmpYSOtvV3LadG2XXBWEcdVJ1Qvaqb5tWqT6KYh/7HkQ+DiD0MPafi+2ZTAhd1EttTCd2nYUQZVWXvKyrpq5rzsuyrIp8AYA38WaEcByTut21Xa0OiqKYzWa24+7T/p+bVoUpiY90qfVY8hIjPLnYG2VG40/WddsK2ck8y//LB7wY0vTYlCat6pVU2oy97PmSex6C0HuJDACcz+3AD3vzftd2w2DMOI5mbFuRpuyW5s9khHCQhKoflFSr8aCqdgn7vv/ysQGAQRhm7UIoraSUUkVhdO/+e68UGADAse04jJOiFGqQneKcU5q8WtoQ2WD/RbGH/TRlLGWUphB6t+N5yAJMusXg5oOd6zBdVLxu6rYTKk3zIIjDkNzCv/x+K+2iukzyAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Projects with different ViewModel folders" title="Projects with different ViewModel folders" src="/static/46494e2bca0342af9a06e0f3cda0f7cd/05ed2/Projects-with-different-ViewModel-folders.png" srcSet="/static/46494e2bca0342af9a06e0f3cda0f7cd/e9ff0/Projects-with-different-ViewModel-folders.png 180w,/static/46494e2bca0342af9a06e0f3cda0f7cd/f21e7/Projects-with-different-ViewModel-folders.png 360w,/static/46494e2bca0342af9a06e0f3cda0f7cd/05ed2/Projects-with-different-ViewModel-folders.png 430w" sizes="(max-width: 430px) 100vw, 430px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Go ahead and delete one of the <em>ViewModel</em> folders, and move the remaining one from the project to the shared files on the bottom. The end result should look something like this:</p><p><a href="/2108ba16d2cabf4170b5d7c899bc7d09/Projects-with-shared-ViewModel-folder.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:430px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:117.77777777777779%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAC20lEQVQ4y42T3W7eNACGc8bfBQykAfqS2E7yJbGdOP+J82PHTraWrWjAWQ+QdjgB7dZ9KxQ2iWMugUsAtO+ISrRcGipFCLVpmfQc2Xrs169tw3p5vvrh3Pz+zH71553jP6yX5+8dnr518PvbB6fvHC7z7uHp3ZOzuydnBkvLOCk7MVVc1K0UaqfuRj7opGh9kt6EFyYeTowyy4skafKsZKxkrEpZSmnB4sj3It9dhHqojMk8dIZ6/KP+5md5vB02v+nvtuL4tfr29XyyzQ5+jb5ehn71S/p0WxxtjWTny2n/YPfJT/X+K/bZM/pok35+lH2x8T/dOA+fe3svFnEfbtwHR4YDLOYDzuNZdX2ZTqKpUyp4qbtiqJMq9uHHH9gf3rkO+Oh9AwDkrUMcxULdV2rafbDX8M5bBwGmQUhcLwDIA8i9DnQ8AwDoel5EqOhqKVXLWxxi07RWK3O1Mk3TMk3LsmwA4BUgRAaEEEBEcbj/SPe9KIrCXwdBEBJCMSaE0IhGvh/YNliQAYAIOUEQNr3SSks5Tnruu47FrCjKPM+rsiKELssQIgAgxmScd4ZuUEqPcuzbriwrjPFl8ltiI9sG68AXYhx6OU2zlKNWOo5jf+0j6DiOi5CDkLMsE0IzXoxq4g3vu55zztuurGretLxpqqqpqrrIiyv+P2d2XQ+HpGkHKeS9+X6W5ZZlARvaNvgvy4U5jhdRsqtqpTRveBgElmVDiC7ruIl/d15TSibZjKPquz5hScKSm3paKCwMiZw/4Q0XUl4s0Xa8aeOYXU+7IHu+P0g9DEIr3badGASlEULu/++MCWFtck8LOVxcVZZmCDpgqaTlwlhE9+am7wetpyLPVyvzFu1qbEIoq7pBKCFkWZQE0zeUoW3bCCHXddd+SC8+QoQxeSMZINeGrgUdCyD776GLOYgun+QtOI5rQDaAbITpaGcqjMu26ftukELFcer7OAjILfwFTkUqk2hAWsEAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Projects with shared ViewModel folder" title="Projects with shared ViewModel folder" src="/static/2108ba16d2cabf4170b5d7c899bc7d09/05ed2/Projects-with-shared-ViewModel-folder.png" srcSet="/static/2108ba16d2cabf4170b5d7c899bc7d09/e9ff0/Projects-with-shared-ViewModel-folder.png 180w,/static/2108ba16d2cabf4170b5d7c899bc7d09/f21e7/Projects-with-shared-ViewModel-folder.png 360w,/static/2108ba16d2cabf4170b5d7c899bc7d09/05ed2/Projects-with-shared-ViewModel-folder.png 430w" sizes="(max-width: 430px) 100vw, 430px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>We now we need to register the <code>IMessageBoxService</code> with the <code>ViewModelLocator</code> so that we can use it in the <code>MainViewModel</code> to show message popups in the app!</p><p>Edit the <em>ViewModelLocator.cs</em> file and change it to the following:</p><pre><code class="language-csharp">using Cimbalino.Toolkit.Services;
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;

namespace App1.ViewModel
{
    public class ViewModelLocator
    {
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);

            SimpleIoc.Default.Register&lt;IMessageBoxService, MessageBoxService&gt;();

            SimpleIoc.Default.Register&lt;MainViewModel&gt;();
        }

        public MainViewModel Main
        {
            get
            {
                return ServiceLocator.Current.GetInstance&lt;MainViewModel&gt;();
            }
        }

        public static void Cleanup()
        {
            // TODO Clear the ViewModels
        }
    }
}
</code></pre><p>As you can see above, we registered the <code>IMessageBoxService</code> with the <abbr title="Model View ViewModel">MVVM</abbr> Light Toolkit IoC Container by calling <code>SimpleIoc.Default.Register&lt;IMessageBoxService, MessageBoxService&gt;()</code>, and this is how we will use all of the services provided by Cimbalino Toolkit - and <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/tree/master/src/Cimbalino.Toolkit.Core%20%28Portable%29/Services">there are quite a lot of them</a>!!</p><p>Now open the <em>MainViewModel.cs</em> file and change it to the following code:</p><pre><code class="language-csharp">using Cimbalino.Toolkit.Services;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;

namespace App1.ViewModel
{
    public class MainViewModel : ViewModelBase
    {
        private string _name;

        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                Set(ref _name, value);
            }
        }

        public RelayCommand SayHelloCommand { get; private set; }

        public MainViewModel(IMessageBoxService messageBoxService)
        {
            SayHelloCommand = new RelayCommand(async () =&gt; await messageBoxService.ShowAsync(&quot;Hello &quot; + Name + &quot;!&quot;));
        }
    }
}
</code></pre><p>We started by adding a couple of properties, <code>Name</code> and <code>SayHelloCommand</code>, that we are going to bind to the view.</p><p>We can also see a <code>IMessageBoxService</code> parameter in the <code>MainViewModel</code> constructor, which the IoC Container will satisfy by creating an instance of <code>MessageBoxService</code> and providing it to the constructor.</p><p>Inside the constructor, we declared what will happen when the <code>SayHelloCommand</code> is invoked: show a popup message box with the input name.</p><p>That takes care of the view model, time to work on the view!</p><p>On the shared files project, create a new folder named <em>View</em>, and inside it create a new user control named <em>MainUserControl.xaml</em> with the following content:</p><pre><code class="language-xml">&lt;UserControl x:Class=&quot;App1.View.MainUserControl&quot;
             xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
             xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
             xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
             xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
             DataContext=&quot;{Binding Main,
                                   Source={StaticResource Locator}}&quot;
             d:DesignHeight=&quot;300&quot;
             d:DesignWidth=&quot;400&quot;
             mc:Ignorable=&quot;d&quot;&gt;

    &lt;StackPanel&gt;
        &lt;TextBlock Text=&quot;name&quot; /&gt;
        &lt;TextBox Text=&quot;{Binding Name, Mode=TwoWay}&quot; /&gt;
        &lt;Button Command=&quot;{Binding SayHelloCommand, Mode=OneTime}&quot; Content=&quot;Say Hello&quot; /&gt;
    &lt;/StackPanel&gt;
&lt;/UserControl&gt;
</code></pre><p>For the view we will use root <code>StackPanel</code> control, containing a <code>TextBlock</code> with a “name” label, a <em>TextBox</em> binded to the <code>Name</code> property in the view model, and a <code>Button</code> binded to the <code>SayHelloCommand</code> property.</p><p>Notice also on the top of the file that we set the user control <code>DataContext</code> property to use the <code>ViewModelLocator.Main</code> property, which returns the instance of the <code>MainViewModel</code>.</p><p>Now all that we needed is to add our <code>MainUserControl</code> to the <em>MainPage.xaml</em> file in each of the app projects. In the end, each of the <em>MainPage.xaml</em> files should be similar to this:</p><pre><code class="language-xml">&lt;Page x:Class=&quot;App1.MainPage&quot;
      xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
      xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;
      xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
      xmlns:view=&quot;using:App1.View&quot;
      mc:Ignorable=&quot;d&quot;&gt;

    &lt;Grid&gt;
        &lt;view:MainUserControl /&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre><p>And… we are done!!!</p><p>Just run the Windows project and the Windows Phone project to confirm that our shared code does in fact work across the two platforms! :)</p><p>To make things even easier, you can download the full solution <a href="/60e204914585efb958a9c806beb189b4/App1.zip">here</a>!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit, step by step!]]></title>
            <link>https://www.pedrolamas.com/2015/01/05/cimbalino-toolkit-step-by-step/</link>
            <guid>https://www.pedrolamas.com/2015/01/05/cimbalino-toolkit-step-by-step/</guid>
            <pubDate>Mon, 05 Jan 2015 19:57:58 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit, step by step!" class="webfeedsFeaturedVisual" /></p><p>One of the biggest complaints I always had about <a href="http://cimbalino.org">Cimbalino Toolkit</a> is the lack of documentation and samples!</p><p>Granted, some awesome developers like <a href="https://twitter.com/saramgsilva">Sara Silva</a> and <a href="https://twitter.com/scottisafool">Scott Lovegrove</a> have done <strong>a lot more</strong> than I have to promote the toolkit and write some really good code using it, but I think it’s time I take on some of that work!</p><p>As such, I’m now making an effort to regularly write articles on Universal Apps development with Cimbalino Toolkit step by step, and here is the first one…</p><h2>Adding the Cimbalino Toolkit NuGet to a Universal App</h2><p>Open Visual Studio 2013, click <em>File -&gt; New -&gt; Project</em>, on the Templates on the left select <em>Store Apps -&gt; Universal Apps</em>, on the right select <em>Blank App (Universal Apps)</em>, pick a name and hit <em>Ok</em> to save the solution!</p><p><a href="/83be990bc96fea827d50d8e3e16b1c75/Creating-a-blank-Universal-App-project.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:68.88888888888889%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACWklEQVQoz23QSW/TQBgGYP+Vxna8zdjjWT2e8TJ2nKaN4y5R29AWLiAEEuLEBYkLFaLrCQ78XeT00KIiPYfRp3n1LdavN0c3m350trzd9A+Xh/cXw81meftq9WPTX53sXW/27y6G6/OD67Pl3flwdz48XA4/T/vfJ4O1mC1wVkYJg2nG87rq9kzXq2peNIu8aDEvENNCt0J3iOayMESoBHMvYbultuZlZZqOMxFD1LadUooSJjNJMAv8MAyjwA9RkuKUEMKODtcHw9HRwXE33x9KbQmUClms16dKlca0ZV3hlHDGKaWMcpQgz/OTBMVxHAQR55KxjLMsAGg345bEREht6jbPi6oylLIoAgDEAEAI40dxnARB6I+DwCAAUQhdH4zhnFDTzLUqESJCyJ2dieO4tu28FIbAmLZtu1nbFXV73BorS3FZNUoVECIpc8dxXXf6km07COHZrOOcZ0KYWfd6WFoSY102lPA4TrMst23nv+HJxMaYKqVt2wZRlBC67hpLc1E380zkcZxKqZ6FvWfGzhAmy2W/WOz1y75b7J8uOsvkqpnttm2XppRz4Wzndrd7PxkLThCEUmqtS63KvDCHphrDKeEoIQAkACS+P151Csk0Zlt8CtljMQgi34+iKI4hcgM4z7hVMOa6XgKR4JJgTokgmGOmMC8wL9ItgkWKaJbldWWiCHhTz556M5palda2H4UQ6boTeU24ihIKR+RJyr0Q7a8O3r7/kJd1jMgkAIYR66wUvWQrSVeS9Rnts/Gxyv81fmBLgbsUfP/88c/Vt/uvX+4+vfsLZ6G5YGDJcisAAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Creating a blank Universal App project" title="Creating a blank Universal App project" src="/static/83be990bc96fea827d50d8e3e16b1c75/37523/Creating-a-blank-Universal-App-project.png" srcSet="/static/83be990bc96fea827d50d8e3e16b1c75/e9ff0/Creating-a-blank-Universal-App-project.png 180w,/static/83be990bc96fea827d50d8e3e16b1c75/f21e7/Creating-a-blank-Universal-App-project.png 360w,/static/83be990bc96fea827d50d8e3e16b1c75/37523/Creating-a-blank-Universal-App-project.png 720w,/static/83be990bc96fea827d50d8e3e16b1c75/a0b80/Creating-a-blank-Universal-App-project.png 955w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Click <em>Tools -&gt; NuGet Package Manager -&gt; Manage NuGet Packages for Solution…</em>.</p><p>On the top right of the <em>Manage NuGet Packages</em> window you will see a search box; type “Cimbalino” on it and press <em>Enter</em>. You should now be seeing two packages: “Cimbalino Toolkit Core” (compatible with background agents) and “Cimbalino Toolkit” (main component)</p><p><a href="/718d5f5c631a4fdc64783bd609931c4d/Installing-Cimbalino-Toolkit-with-NuGet-Package-Manager.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:66.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACAUlEQVQoz5XQTY+TQACAYf5LgYHCDDCUjwGGaYFhWoZC6Ue0btLdNZ6MB1dTr+vXxY3Z3XjQv2tckx5M3GjyXp/Lq/y4GO7P1/fnw82+/bJv787k1718v64/bMTH3eLTbnG9rq9X1ec1vzsM3y42t2f97WG42fffn6yUQcyDrPBDivwEuROnf1ltLpf9li9Wlegq0WVT8er18dnhhU9YUjQemSE/Vm08z6nSTfM0Yz4OHAe7NsTti/lw2K13fbcRteRcsryUTS9qWRSCN6swmWE8McawTWJlKIuFXNGMQejBsaUV+7hseTFjbBpFcRwTQkgYhkAHlLJ2OYRRil3ftN02JYqkKXR820YQuhC6YDRSR6qq6ZqmA2AYhgmAAYCha9oYp0YqgUdsC+omlEms1HFojBFC7gN2dGBqOtB1oD34U6ORmtCi6bZZxmjG4pT1LFMEiUzLQfA3dnXd+IOdMKV51/at7Ot6nrFymNJ/xaqqYRws2142S9ksSz4fpvl/YN8Ph/VWiHlZ8IjQjqYKjwNgQttGloVs23kEhyGpSlHMqqKo8IQss0TZippN+WxWlgUncapp4G84CKI0yT1vgnEAHf8XftosuJC8qtMs9/1Q08Ep8HD+lGlaYwuNLQRtx7AcmRLl6vLw5uptEhFkQc/x8KP5LnZsxFJ6PL47Pj/8BIBoradxhWmYAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Installing Cimbalino Toolkit with NuGet Package Manager" title="Installing Cimbalino Toolkit with NuGet Package Manager" src="/static/718d5f5c631a4fdc64783bd609931c4d/37523/Installing-Cimbalino-Toolkit-with-NuGet-Package-Manager.png" srcSet="/static/718d5f5c631a4fdc64783bd609931c4d/e9ff0/Installing-Cimbalino-Toolkit-with-NuGet-Package-Manager.png 180w,/static/718d5f5c631a4fdc64783bd609931c4d/f21e7/Installing-Cimbalino-Toolkit-with-NuGet-Package-Manager.png 360w,/static/718d5f5c631a4fdc64783bd609931c4d/37523/Installing-Cimbalino-Toolkit-with-NuGet-Package-Manager.png 720w,/static/718d5f5c631a4fdc64783bd609931c4d/1cfc2/Installing-Cimbalino-Toolkit-with-NuGet-Package-Manager.png 900w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Select “Cimbalino Toolkit” and click on the <em>Install</em> button. You will now see the <em>Select Project</em> window.</p><p><a href="/48b0dd6f6e427295e2f7fc15dc211f5c/Select-Projects-to-install-package.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:400px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:100%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACBklEQVQ4y+3TTW8SQRjA8f0celNgd2dmZ5ZZoJR3cN9gIVIRRGpKeIuCsFiCrVogGESiRmv0jrcmGo2aGI2mFxujN18OSj+OoZjUWKJeTUx+p8nzT+bwPMyXy/ndbmGyUZh0ftjtFD9dWtlZzX1on3nfXt5pLX+ezhQnnT3d4rcrha+llY/lHPOguHQ1HRtl48NMbHjKGGaMUTY+yMQ6Kb2X0rsntI2U3j+pD9L7rqX1XlIb55PM2ZhM/bJqHPdFNN8xzR/RPSHZF9aCcjQg64GIGlYNu9NjAaIN2Wc4gR7mcFkLMWZcQaKjXq2tX1xzSg7AQwQFBAVqd0jUKVEHtTvsIhXJPipSFonNhMqYCfUoLyy43Beaze56U8AizyMIMUIzBCEiCOLPCBYtgJgJhTETihUQBDGlzl6/W2+bVivHccDG8hwHpyUS/xBjgYhEOm82SrWKjeV5HvE84jjIcQBC/LvYAgjB09eDP5xrfvyX/sf/ZKxaeIwFMlvjgyDEEAhTEEOIAZiezREWNeIK0zBkgCWn5Nq7oTkWF/0eT9DrDbrdPveCx+cNhAIh6vKacYUpq6FDVsRC0QrILyw8ZgVp/PjV09dvn2+/uzt+2B/devlme+vRk61nL9ayS8yd00ZJCdai4ao+Ry0audGobrbMzZZ5vVoZFHP3Vs/drpduNir388nv0ucpzZBy7e8AAAAASUVORK5CYII=&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Select Projects to install package" title="Select Projects to install package" src="/static/48b0dd6f6e427295e2f7fc15dc211f5c/e17e5/Select-Projects-to-install-package.png" srcSet="/static/48b0dd6f6e427295e2f7fc15dc211f5c/e9ff0/Select-Projects-to-install-package.png 180w,/static/48b0dd6f6e427295e2f7fc15dc211f5c/f21e7/Select-Projects-to-install-package.png 360w,/static/48b0dd6f6e427295e2f7fc15dc211f5c/e17e5/Select-Projects-to-install-package.png 400w" sizes="(max-width: 400px) 100vw, 400px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Leave all projects of the solution selected and click <em>Ok</em>. You will now see the <em>License Acceptance</em> window, showing the licenses for all packages that will be installed.</p><p><a href="/d29036a9b2d79f364db6e57547e376eb/License-Acceptance.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:400px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:112.77777777777777%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAIAAACEf/j0AAAACXBIWXMAAA7DAAAOwwHHb6hkAAACm0lEQVQ4y+2SS2sTURTH51u4UIqkbTKvO++5N5NJJjOTeecxM5kkCKltY7F51C5sFyoNCEojbl0oaLFWqC7ED6HFrbRgv49M0vqoLroVhB+X3z3c/zlcONjx/ZXTnd63c053eicPVo+2u0db3S/bS0db3c9b3U93u19/fTbunQyWjntL2KuV8FHiTtrupO3tttxJy3ucOOPIGofWw9geR/ZOaI0je/rGm7S9J23/acffbXrPbtSwrmMqhms5VdPxDcs3LM/yakbFtdyqZti66Zi2V9QM3XINyzNtT0IqAfgs4MsIYiuuQbGCyIsiL8qiLHAChHlJhLKMREEWRVkQJFlGBUVVUEHJF+C0zvJSraxhy44xx1UyrJ7hKws0wnM4QdApOHUmBE1RzA9omgU0i5NMVSthy45+nRRzJL9ICos4wHEylyNyWYIgaZJMW5AkIAgKx0mKYhmGB4BjAEdQ7CxsZEQ7K1qLkovzRZqiKYqdTbgAANyM38I4EBjAg2nXy/BnmAOX5n/4Xwzbeo7m6POVon5K6tS0cr7V50IxWQKk4VXX5KGaRwVZRhAqCCmynJdkBOV8eoUFhBQIz0CoMENGak0vY2tVxw7CJG6F9SgI6nGcBF41COqtpNNoxI161IySpNmOoiSOW7Vqo5V0wrDpBvWGUcZuBbbfSOIw1vWKqmqFQklVS6qqaSW9rJmlYllRijwncpwkCFCSIMeKFAmuzmUqUMZuWmVOzOchoqefATQ7E5oCgGYInCwVtdFgNOgP++sD1/b664PNO5vr/VE6OdHUKxliHqfnCeYCCyR7LZPzG813Hz6+2NvfOzhcXuu/OXz/8vXB8/23kedhux3/tqdvBObIN/7KMD3NjcAcTn0YpN739Huh/R2eCkmtz4QIsQAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="License Acceptance" title="License Acceptance" src="/static/d29036a9b2d79f364db6e57547e376eb/e17e5/License-Acceptance.png" srcSet="/static/d29036a9b2d79f364db6e57547e376eb/e9ff0/License-Acceptance.png 180w,/static/d29036a9b2d79f364db6e57547e376eb/f21e7/License-Acceptance.png 360w,/static/d29036a9b2d79f364db6e57547e376eb/e17e5/License-Acceptance.png 400w" sizes="(max-width: 400px) 100vw, 400px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Please review the data and then click <em>I accept</em> to continue with the installation.</p><p>After this step, you should now have returned to the <em>Manage NuGet Packages</em> window, and a green checkmark should now be shown on the side of each of the toolkit components.</p><p><a href="/99c893efe372d42d454591e426dad8ff/Packages-successfuly-installed.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:720px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:66.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACAklEQVQoz5XQW2vUQACG4fwWN8kkm8wkmWySSTI5TQ6TbE6bPahLYVvFAwheVK+8EaugWKQtXujfFVcoIlgU3tsHPj7h+9l0c7q+OZ0u993nfXd90n7Zt+/W1cWGv981H3bN26m82PBP95vrw/T1bHN1Ml4dpsv9+O3BSph47VBmuxGyA2QujPFFsXncD9uyHgs+VM0qYU3MGpIxEud+1lh+hmwi6riOI2FI45AmNnYMA5s6xN2Tejrs1rth2FRVy3lX877mXVaUeVGXzcoNMowXyhx2ARGmnDXtKqIJhBacaxLbk7wrWZakqecRQnzPI67raYYWJ2nXr1wvxKat6mYX+kIbhdCwdR1BaEJogtlMnImiKEuSDICiKCoACgCKeE+c41AJW2D5ugZlFbYBESriKnOEkHnEhgxUSQayDCRJ/r3ZTAwithy2lCYRTUiYjAkVuO+pmoHgL2zKsvIHu8VRFA/d2LVjVdU0yac0+lcsihLGTt+N7bJvl31e1lMa/we2bXdabzmvc1Z6fjREoVASB6hQ15GmIV037sCu6xc5Z1nBWIEXfk8DYcurJC2zLM9Z6ZNQksDfsON4YRBb1gLjBTTsn/jhsil5WxZVSGPbdiUZ3AaOz9+mqtpcQ/PjQKCbbegL548Or85fB56PNGgZFr47E5s6ojR59ubjy6fPfwCnJK0BPCq2IQAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Packages successfuly installed" title="Packages successfuly installed" src="/static/99c893efe372d42d454591e426dad8ff/37523/Packages-successfuly-installed.png" srcSet="/static/99c893efe372d42d454591e426dad8ff/e9ff0/Packages-successfuly-installed.png 180w,/static/99c893efe372d42d454591e426dad8ff/f21e7/Packages-successfuly-installed.png 360w,/static/99c893efe372d42d454591e426dad8ff/37523/Packages-successfuly-installed.png 720w,/static/99c893efe372d42d454591e426dad8ff/1cfc2/Packages-successfuly-installed.png 900w" sizes="(max-width: 720px) 100vw, 720px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Congratulations: you have now successfully installed the Cimbalino Toolkit in your project! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bye MixRadio!]]></title>
            <link>https://www.pedrolamas.com/2014/12/12/bye-mixradio/</link>
            <guid>https://www.pedrolamas.com/2014/12/12/bye-mixradio/</guid>
            <pubDate>Fri, 12 Dec 2014 15:36:30 GMT</pubDate>
            <content:encoded><![CDATA[<p>Today was my last day as a MixRadio employee.</p><p>After <a href="/2014/04/25/bye-nokia-hello-microsoft/">Microsoft completed the acquisition of the Nokia Devices &amp; Services business</a>, MixRadio and all of it’s employees became part of Microsoft.</p><p>However, a couple of weeks after that Microsoft started a full reorganization and decisions were quickly made to ensure <a href="http://www.theguardian.com/technology/2014/jul/18/nokia-mixradio-streaming-music-ios-android">MixRadio would become a separate entity</a>.</p><p>So the only visible changes resulting from the acquisition are actually the company signs around the office, the “blue badges”, and the new @microsoft.com email addresses… no other real integration ever happened for MixRadio, so I can’t actually say I felt like a Microsoft employee during this short period!</p><p>As a result of all this, plans have been made for the future of MixRadio as a new company that made me believe this is the right time for our paths to come apart.</p><p>During my time with the company, I was involved in almost every aspect of the MixRadio Windows Phone client development; every time I open the MixRadio 4.x client in my phone, I can’t help but to feel proud of what this team accomplished.</p><p>I wish the very best to MixRadio and all my colleagues in the upcoming future, and I’m sure to keep using MixRadio service as it is by far one of the best streaming music services available!</p><p>As for me, I will keep doing what I love, always related with development under Microsoft Technologies, but more to come on this over the next weeks…</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrading from the IsolatedStorageSettings to ApplicationData.LocalSettings]]></title>
            <link>https://www.pedrolamas.com/2014/08/14/upgrading-from-the-isolatedstoragesettings-to-applicationdata-localsettings/</link>
            <guid>https://www.pedrolamas.com/2014/08/14/upgrading-from-the-isolatedstoragesettings-to-applicationdata-localsettings/</guid>
            <pubDate>Thu, 14 Aug 2014 14:11:26 GMT</pubDate>
            <content:encoded><![CDATA[<p>When Windows Phone 7 came out, the <abbr title="Software Development Kit">SDK</abbr> provided a really easy class to maintain the app settings: the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/system.io.isolatedstorage.isolatedstoragesettings%28v=vs.105%29.aspx"><strong>IsolatedStorageSettings</strong></a>.</p><p>Basically, the class is an <code>IDictionary&lt;string, object&gt;</code> with a <code>Save()</code> method that will take the instance and serialize it to a file called ”__ApplicationSettings” in the root of the app’s isolated storage.</p><p>Now if you upgraded your app from Windows Phone Silverlight 8.0 to the Windows Runtime model, you’ll probably want to migrate the settings from the old format to the new one, right?</p><p>Problem is that though the class exists in Windows Phone Silverlight apps, it does not in the new Windows Runtime apps, being replaced with <a href="http://msdn.microsoft.com/library/windows/apps/windows.storage.applicationdata.localsettings.aspx"><strong>ApplicationData.LocalSettings</strong></a> and <a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.roamingsettings.aspx"><strong>ApplicationData.RoamingSettings</strong></a> instead.</p><p>So the only solution will be doing it ourselves, by reading and deserializing the “old” settings file!</p><p>Here’s a sample of the content of an ”__ApplicationSettings” file from one of my tests:</p><pre><code class="language-text">PhoneApp1.Address, PhoneApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
&lt;ArrayOfKeyValueOfstringanyType xmlns:i=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://schemas.microsoft.com/2003/10/Serialization/Arrays&quot;&gt;&lt;KeyValueOfstringanyType&gt;&lt;Key&gt;Name&lt;/Key&gt;&lt;Value xmlns:d3p1=&quot;http://www.w3.org/2001/XMLSchema&quot; i:type=&quot;d3p1:string&quot;&gt;John Doe&lt;/Value&gt;&lt;/KeyValueOfstringanyType&gt;&lt;KeyValueOfstringanyType&gt;&lt;Key&gt;Age&lt;/Key&gt;&lt;Value xmlns:d3p1=&quot;http://www.w3.org/2001/XMLSchema&quot; i:type=&quot;d3p1:int&quot;&gt;20&lt;/Value&gt;&lt;/KeyValueOfstringanyType&gt;&lt;KeyValueOfstringanyType&gt;&lt;Key&gt;Country&lt;/Key&gt;&lt;Value xmlns:d3p1=&quot;http://schemas.datacontract.org/2004/07/PhoneApp1&quot; i:type=&quot;d3p1:Address&quot;&gt;&lt;d3p1:Code&gt;UK&lt;/d3p1:Code&gt;&lt;d3p1:Name&gt;United Kingdom&lt;/d3p1:Name&gt;&lt;/Value&gt;&lt;/KeyValueOfstringanyType&gt;&lt;/ArrayOfKeyValueOfstringanyType&gt;
</code></pre><p>By looking at the contents of some samples of settings file like the one above, here’s what we can learn:</p><ul><li>the file has always two lines (second line in the above sample is auto-wrapped to fit the post!)</li><li>the first line has the known types full names that should be loaded and passed on to the <a href="http://msdn.microsoft.com/en-us/library/windows/apps/system.runtime.serialization.datacontractserializer%28v=vs.105%29.aspx">DataContractSerializer</a> constructor, each properly separated by a null char</li><li>if only basic types are used, the first line will be empty</li><li>the second line is the serialized xml data</li></ul><p>So I wrote the following code snippet to read and deserialize the values from ”__ApplicationSetting” to an <code>IEnumerable&lt;KeyValuePair&lt;string, object&gt;&gt;</code>:</p><pre><code class="language-csharp">public async Task&lt;IEnumerable&lt;KeyValuePair&lt;string, object&gt;&gt;&gt; GetValuesAsync()
{
    try
    {
        using (var fileStream = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(&quot;__ApplicationSettings&quot;))
        {
            using (var streamReader = new StreamReader(fileStream))
            {
                var line = streamReader.ReadLine() ?? string.Empty;

                var knownTypes = line.Split(&#x27;&#x27;)
                    .Where(x =&gt; !string.IsNullOrEmpty(x))
                    .Select(Type.GetType)
                    .ToArray();

                fileStream.Position = line.Length + Environment.NewLine.Length;

                var serializer = new DataContractSerializer(typeof(Dictionary&lt;string, object&gt;), knownTypes);

                return (Dictionary&lt;string, object&gt;)serializer.ReadObject(fileStream);
            }
        }
    }
    catch
    {
        return new Dictionary&lt;string, object&gt;();
    }
}
</code></pre><p>So all you now have to do is call the <code>GetValuesAsync()</code> method above and load those values to one of the new Settings repositories!</p><h2>The Cimbalino Toolkit way</h2><p>Starting in <a href="http://cimbalino.org">Cimbalino Toolkit</a> 1.2.0, you’ll be able to use the new <a href="https://github.com/Cimbalino/Cimbalino-Toolkit/blob/master/src/Cimbalino.Toolkit.Core%20%28Portable%29/Services/IApplicationSettingsService.cs"><strong>IApplicationSettingsService</strong></a> to access <code>Local</code>, <code>Roaming</code>, and <code>Legacy</code> app settings.</p><p>In case that wasn’t clear from the names, the <code>Legacy</code> settings will allow you to get the values on the ”__ApplicationSettings” file (do note that only the Values property is implemented, so it’s read-only).</p><p>Here are the platform rules for the <code>ISettingsService</code>:</p><ul><li><strong>Local</strong><ul><li>Supported in all platforms</li></ul></li><li><strong>Roaming</strong><ul><li>Supported in all platforms except Windows Phone Silverlight 8.0</li></ul></li><li><strong>Legacy</strong><ul><li>Only supported in Windows Phone</li></ul></li></ul><p>One last suggestion: after migrating the legacy settings remember to delete the ”__ApplicationSettings” file as it won’t be needed again! ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Toolkit 1.0.0]]></title>
            <link>https://www.pedrolamas.com/2014/07/24/cimbalino-toolkit-1-0-0/</link>
            <guid>https://www.pedrolamas.com/2014/07/24/cimbalino-toolkit-1-0-0/</guid>
            <pubDate>Thu, 24 Jul 2014 11:25:36 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/d49b90c9d9b19e8bf9425bb5fe82ce82/Cimbalino.Toolkit@4x-400x270.png" alt="Cimbalino Toolkit 1.0.0" class="webfeedsFeaturedVisual" /></p><p>In case you missed it, <strong>there is a new and improved <a href="http://cimbalino.org">Cimbalino Toolkit</a> now available</strong>, supporting the following platforms:</p><ul><li>Windows Phone Silverlight 8.0 and 8.1 apps (<abbr title="Windows Phone 8">WP8</abbr>)</li><li>Windows Phone 8.1 apps (WPA81)</li><li>Windows Store 8.1 apps (Win81)</li></ul><h2>The long story</h2><p>About 3 years ago, the first version of Cimbalino Windows Phone Toolkit was released as a <a href="https://www.nuget.org/packages/Cimbalino.Phone.Toolkit/">NuGet package</a> with <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit">full source code hosted in GitHub</a> to help every on the development of Windows Phone apps!</p><p>Back then, Windows Phone 7.0 was the only version available, and that meant that some technical decisions had to be made that influenced the toolkit architecture!</p><p>The main one was that <abbr title="Windows Phone 7">WP7</abbr> apps Marketplace ingestion would automatically detect every component used in a particular app, and add the required Capabilities for them; so if the toolkit was a single assembly, you’d get your app with the full Capabilities list in the requirements, even if your app didn’t actually use them…</p><p>There was also some limitations on the available <abbr title="Application Programming Interface">API</abbr>’s for Background Agents and once again, the Marketplace ingestion of an app would basically fail if it detected one of those forbidden <abbr title="Application Programming Interface">API</abbr>‘s.</p><p>So the toolkit ended up divided like so:</p><p><a href="/b668694d296999951e70d8b29b56bcf2/Cimbalino-Windows-Phone-Toolkit.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:450px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:77.77777777777777%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAIAAACZeshMAAAACXBIWXMAAA7CAAAOwgEVKEqAAAADBElEQVQoz32T60+ScRTHf2u9qRf+Gb5uzWUqoZFOnfogXlizpXibZZkVq3ntqsP7ZgpqWCqPIPCk6NSizEqcmpYmiIrzCmYIDAXkgUce4NfAtdWyzj4vzotzds737HsA/E94vRBCt8c7xL7bERONJjEE9AQBHUET6Z3xcRgrA3i8RzXHh8frNdsIaUZ609kzrVQKLyS4JfR8CyW0+VxQR2wM+K3Q/Tdu0m2xH24pxuZFIhUmVUn9YFKVRLIilwPNDm6wun7teMxko8U5fP+eAIkXXWYKU5OFzBQhMwVNYvRmZ4G0xiXxpAlCr6W+Yp+dZym5ZSkusBQVWEoK9wuzDl6JzC4oy8ttCQtpj4rk0yL4ly62R9LaIqjdyUkgvWmpZ8rksu1rAwO3ANAFnNCdBtpTQBdwcguA7StMA4Tbik8qTLrYL/Mh61uUydR9vasjIyCLp0HHd0knTjQ8cbKzidIbRHG+j9KbxO0MAkONh3Ag/zovNITvH8inRbRH0p6HU0XMVMDialCF3kWSL6esnLfmuvd7tX7qR/cq5Gb5kv3ATrwpLkYT6T7NzBQRM9UvPqX/Wh5g8TSicf2e1Z7NXYqtmE+sViEcJVKlZNSoaI/m6ga0Xo9ndXR0DkWVErEPcY9S3DMvEi4PDwEWb4U/osMdDvn8XrdiVzJhEE8YeiYMkkmDYEw/vWaz4gSWm8MNDmoLv9BKCWujUtqovkSQiICrTcudH3cOcEfLux+PsU2OTFvZ54Mj05aLN4ZmzRDCQTb7RXSUgI50JsR1IfFdSILPYZkskN68LBzXW2x4Jk8TXalEqhfiOKr4KhVSs0B9+K1haBtCSDicLjvuwv+AJAiQ9mwZVeg9bvKDeh+bMvbPmGR++r+YpFNG5Zb9X/6BEIIMrqZboccdzvrB7SLherlks0y8USbefCDZZAvWej8bfT7zHN/td9iEgSTJnFYNUr2QXK9m1KqT6tSpDYuRT5WNr78fPdbxzXe61o6usqCzz6xZv67bjphdt02vWrUm4j9r/wS247+6yNC/bQAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Cimbalino Windows Phone Toolkit" title="Cimbalino Windows Phone Toolkit" src="/static/5211207d078301bf552ad08142457b90/fc2a6/Cimbalino-Windows-Phone-Toolkit-thumb.png" srcSet="/static/5211207d078301bf552ad08142457b90/e9ff0/Cimbalino-Windows-Phone-Toolkit-thumb.png 180w,/static/5211207d078301bf552ad08142457b90/f21e7/Cimbalino-Windows-Phone-Toolkit-thumb.png 360w,/static/5211207d078301bf552ad08142457b90/fc2a6/Cimbalino-Windows-Phone-Toolkit-thumb.png 450w" sizes="(max-width: 450px) 100vw, 450px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>In light blue are the components that may be used with Background Agents. The rest of the components are divided by Capabilities or 3rd party components requirements.</p><p>Then came Windows 8.0 and Windows Phone 8.0, and Microsoft removed the Marketplace Capabilities auto-detection feature (the developer has to declare them manually in the app manifest), so we can now have drop that specific component division requirement! :)</p><p>This small change allowed to reduce the create a <strong>new Cimbalino Toolkit with just 2 NuGet packages!</strong></p><p>There is still a lot of work to be done to port everything from the old toolkit to the new one, but here’s some of the things already working:</p><ul><li>ApplicationBarBehavior, MultiApplicationBarBehavior, MultiBindingBehavior</li><li>StorageService, EmailComposeService, MessageBoxService, NavigationService, and others…</li><li>Most of the extension methods have already been ported, including the <abbr title="Portable Network Graphics">PNG</abbr> support ones</li><li>Most of the value converters</li></ul><p>Also, there is the need to write some new samples and documentation, so if you can I could surely use the help!!! ;)</p><h2><abbr title="Too Long">TL</abbr>;<abbr title="Didn&#x27;t Read">DR</abbr></h2><p>Here are the new <strong>Cimbalino Toolkit</strong> NuGet packages:</p><ul><li><a href="https://www.nuget.org/packages/Cimbalino.Toolkit.Core">Cimbalino.Toolkit.Core</a> - The core portion of the toolkit (compatible with background agents)</li><li><a href="https://www.nuget.org/packages/Cimbalino.Toolkit">Cimbalino.Toolkit</a> - The main component of the toolkit</li></ul><p>Please check back soon to read about what’s new and what changed! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bye Nokia... Hello Microsoft!]]></title>
            <link>https://www.pedrolamas.com/2014/04/25/bye-nokia-hello-microsoft/</link>
            <guid>https://www.pedrolamas.com/2014/04/25/bye-nokia-hello-microsoft/</guid>
            <pubDate>Fri, 25 Apr 2014 13:53:45 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/49b6eeafaacf672dd7c37099cd50ba86/Microsoft-300x270.png" alt="Bye Nokia... Hello Microsoft!" class="webfeedsFeaturedVisual" /></p><p>The deal to transfer substantially all of the Nokia Devices &amp; Services business to Microsoft has now officially been closed.</p><p>With it, <strong>I proudly become a Microsoft employee!</strong> :)</p><p>I will always cherish the moment I decided in moving to the <abbr title="United Kingdom">UK</abbr> to work for Nokia (even if that stopped any chance of receiving the Microsoft <abbr title="Most Valuable Professional">MVP</abbr> award, but that’s another story!).</p><p>Nokia made me feel that I could actually make a difference with my work, and I truly appreciate the company for the opportunity!</p><p>I’ve been working with Microsoft technologies for more time than I can remember, both as a user and also as an IT professional, and I consider getting the “blue badge” as a giant career step for me!</p><p>In the present moment this doesn’t bring any significant changes: I’ll carry on working in the MixRadio apps here in Bristol, as I did until today!</p><p>Thank you Nokia, it’s been really fun… Hello Microsoft! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit Updated to v3.2.3]]></title>
            <link>https://www.pedrolamas.com/2014/04/11/cimbalino-windows-phone-toolkit-updated-to-v3-2-3/</link>
            <guid>https://www.pedrolamas.com/2014/04/11/cimbalino-windows-phone-toolkit-updated-to-v3-2-3/</guid>
            <pubDate>Fri, 11 Apr 2014 11:00:50 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/58e959564fc7425d90e4f09137e0baa2/Cimbalino-Windows-Phone-Toolkit-300x270.png" alt="Cimbalino Windows Phone Toolkit Updated to v3.2.3" class="webfeedsFeaturedVisual" /></p><p>Version 3.2.3 of <a href="http://cimbalino.org"><strong>Cimbalino Windows Phone Toolkit</strong></a> is now available!</p><p>As <a href="/2014/03/15/poll-what-are-your-plans-for-wp7dev/">previously indicated</a>, this will probably be the last version still supporting Windows Phone 7…</p><p>Here’s the change log starting from version 3.2.0 to the current 3.2.3:</p><ul><li><strong>v3.2.1</strong><ul><li>New <strong>WebRequestExtensions</strong></li><li>Ensured that <code>MarketplaceInformationService</code> doesn’t cache the results</li></ul></li><li><strong>v3.2.2</strong><ul><li>New <strong>EventHandlerExtensions</strong></li><li>Improved the <code>MultiBindingBehavior</code> by adding the missing <code>Mode</code> property</li><li>Improved the <code>ShellTileServiceTile</code> to enable tiles update with <abbr title="Extensible Markup Language">XML</abbr> data</li><li>Fixed a couple of issues on <code>MarketplaceInformationService</code> related to “beta apps”</li></ul></li><li><strong>v3.2.3</strong><ul><li>New <strong>SaveRingtoneService</strong></li><li>New <strong>ScreenCaptureBehavior</strong></li><li>New <strong>FrameworkElementExtensions</strong></li><li>DeviceInfo, Location, and UserInfo components can now be used inside Background Agents</li><li>Improved <code>ShellToastService</code> to add the custom sound support</li></ul></li></ul><p>There are other improvements and bug fixes not stated here, but also quite important too! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WrapPanel is great, so please, stop using it!]]></title>
            <link>https://www.pedrolamas.com/2014/03/31/wrappanel-is-great-so-please-stop-using-it/</link>
            <guid>https://www.pedrolamas.com/2014/03/31/wrappanel-is-great-so-please-stop-using-it/</guid>
            <pubDate>Mon, 31 Mar 2014 11:38:46 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/0ea451f6a7fc725594ca969d78507989/WrapPanel-layout-420x270.png" alt="WrapPanel is great, so please, stop using it!" class="webfeedsFeaturedVisual" /></p><p>The <strong>WrapPanel</strong> control (part of the <a href="http://phone.codeplex.com">Windows Phone Toolkit</a>) is a really useful control container.</p><p>Having said that, <strong>you should definitely avoid using it</strong> in your apps if you are planing to use in <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.itemscontrol.itemspanel%28v=vs.105%29.aspx">ListBox.ItemsPanel</a> for large lists items presented with fixed size!!</p><p>To demonstrate my point, let’s say we have a list of 10 items:</p><pre><code class="language-text">{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
</code></pre><p>Now say we want to list 3 items per row and them wrap to the next row, we can use a <code>WrapPanel</code> container control, like so:</p><pre><code class="language-xml">&lt;ListBox x:Name=&quot;ItemsListBox&quot;
            ItemTemplate=&quot;{StaticResource ItemDataTemplate}&quot;&gt;
    &lt;ListBox.ItemsPanel&gt;
        &lt;ItemsPanelTemplate&gt;
            &lt;toolkit:WrapPanel /&gt;
        &lt;/ItemsPanelTemplate&gt;
    &lt;/ListBox.ItemsPanel&gt;
&lt;/ListBox&gt;
</code></pre><p>The resulting items layout will look something like the following picture:</p><p><a href="/c0ba707930a8190dc26c6d8a13c7cf4e/WrapPanel-layout.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:252px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:118.88888888888889%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEaElEQVQ4y5WU+VMbZRjH88ep1SL0oHLY1pbi1Ok1jloEW8c6OuNYe5BAyAU00HJMuWQ6WmiAcLZYS5vsvdlN9sy9m3OzmyxJ9nUWmMpv1ne+P33n/cwzz2kBAITiSt8S71oV+pb52Z0EAECv1rxbUbufd6wKA35ezGgAgDVCti5x7jXR6uOWsDQAwAIA8OPyh1aoxYUetcHXH1PVWj1X0s8N4412+KQTPdYPB7g8AMC+zB+5F2hzo+/fDdxdYA/gLSrT4kZ7ZsOdXqJ7hoZEZRmTr46TF0aIa5PUmUF0AZbe8Mq9RfZTN9IzQ7c64dtPWTRWMuFVQj5q248MdU1RhmGUyrvnHmBNZmTk+AAc5M3IjhX+SG+w1Y2+dz9gX+F5uWzCVEJx+oWhDdHhF+ZfJwEAu9Xaoxcx15rgWRfda0Isa+a8Qcr2ZX54I2rzcVuUzEiahYiX4GhJyJRZuczJ5Uhag0QFFhVGMp19YbFSQCiGkioraRFJYyQtnNI26ZwFEpV4rhLgC0Gh8IbPhxJKtWZUqnU0WgzwBUgw/Zy6CwDgZHWHzQeFwg6bZ9KqWbBIWvPj0gk71O5GjvVDN2dpAIyyXv1iFG8egFtdSJsTRsUCAMCzJjTagqc9aIM1aPNxJrxF50e3ou0e7MoEdXYI75qmQwl1O5y79Ii84CWuTYTa3egSJtMprfcZ1+JCv3kcPuVAfv2TTRZ0i6rXfn+dPD4Ad4wQzU7k+hSVLFTIuPL5KN7mwc578VNOeJPK5tSq1cc12eGLD8mGPqjXxx206mUk2+nFLo8RHQ+w354yABj6bq1nmro4gl96SFx+iIfiCgBg/EWsYxi9Ok5+NoiMPY/GcrqlWKlGsxVW0lhJY9IaL5dTRT1Z0Lk9Z1/xvJ5WdsVshZE0TtYikpos6K/YomU7kicSJUZSI2k1ktYOST0k06FTKpX8V0KmbFb7DZu/OUv/OB/umaGG1gUAQLVau7PAfD9H35oP35qn9xszt5P4apK8MUt/OUFObsfMar/mirM7iSY7dHYIb7LDXz8OpQqVSKrU4cVOOpB2D3ZiAF4nM8VyrdfHNdigzhHiqBX65Q9Gr9YtoaQ2+jx6ehDtmgqfG8a7Z2gyoW5S2Stj5HkvcXU8dHoQXcZkMqH2PuNa3eiNucgpJ3JvkQsKilntdUJu7Au2uNCP+6DvZg6GpHMEP2aHm51IswOG94bE6Rc+sgZbXegH9wOOFT6eq5hwNKMtwukVXHqGpF9GsrW6oVdrm6HMCiav4vIKJsnFCgCATpY2Qpm/wtk1UuakEplQLX+zRUhUxIy5FbxcZvYWAxIVIq6SiQMhUSUoKFi89NbB4+aqWPC4SieVye3Y9KvExHZ8GZMMwwAA1A3jrfYMYBjgkGNaFiql+RCpwRb8ZO8YfGseg7r5FfzHMwxgeckUhjfEM4No90z4/DD+w3z4HeGDG7aEphv7g+0erLEf7p6mjfr/gRGh8POT8O2nzE9PIqNb0YMU3wH+B31GnfN+FZ48AAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="WrapPanel layout" title="WrapPanel layout" src="/static/f5a2bc1e905c3a4f8ee04f3c8e10432c/5e02b/WrapPanel-layout-252x300.png" srcSet="/static/f5a2bc1e905c3a4f8ee04f3c8e10432c/e9ff0/WrapPanel-layout-252x300.png 180w,/static/f5a2bc1e905c3a4f8ee04f3c8e10432c/5e02b/WrapPanel-layout-252x300.png 252w" sizes="(max-width: 252px) 100vw, 252px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>This will work fine with 10 items, but what about 100? Or 1.000? Or even 10.000?</p><p>Using a <code>WrapPanel</code> with a large number of items will cause the control loading time and memory usage to increase, and if you make it large enough, you’ll probably start seeing your app crash with “out of memory” errors…</p><p>Now lets say we first group the items in groups of 3, making the source list look like this:</p><pre><code class="language-text">{ {0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {9} }
</code></pre><p>All we now need is another <code>ItemsControl</code> inside our main <code>ListBox</code> to iterate the each group, something like this:</p><pre><code class="language-xml">&lt;ListBox x:Name=&quot;ItemsListBox&quot;&gt;
    &lt;ListBox.ItemTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;ItemsControl ItemTemplate=&quot;{StaticResource ItemDataTemplate}&quot; ItemsSource=&quot;{Binding}&quot;&gt;
                &lt;ItemsControl.ItemsPanel&gt;
                    &lt;ItemsPanelTemplate&gt;
                        &lt;VirtualizingStackPanel Orientation=&quot;Horizontal&quot; /&gt;
                    &lt;/ItemsPanelTemplate&gt;
                &lt;/ItemsControl.ItemsPanel&gt;
            &lt;/ItemsControl&gt;
        &lt;/DataTemplate&gt;
    &lt;/ListBox.ItemTemplate&gt;
&lt;/ListBox&gt;
</code></pre><p>Here’s the resulting layout schematic:</p><p><a href="/b1ea64414b04bb466552dbc8cb73c91b/Smart-Wrapping-layout.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:252px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:118.88888888888889%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAIAAAB1KUohAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEOUlEQVQ4y5VUbU/bVhjlx01rVwpszUopYi2j3boX+mnlRe20D5s0bdIoSUlIAmQppXQKL91UqVshQEILY6uqJrEdO3GSNnECgcQhxE4cv9x7n8luQPu21bqyrGOfe3zO89ynDQCSe/KdYM4TEu6s5ZZfFAFAM5B/q+DcyE2GBNdGLl9RACDMifZg1hvO21ezwXgJANoAYIMVT9tj3R7mjIO6EeANhKt17bKP7XBS59xM1wQVyR4BgHMtd2os0uNl3vnp5diT1y3yFl/p9jKjy+krfm5kKRXLy2txcXA+MXCXu/4L3zfN/EGVX+bksSeve7306FL6w0nKvZFrkUOceMZhKrc7YkMLPCGkrur9P8c7TWX6fRcVzZnKk+u5U+PRHi/z7u3o2MqxMl+UXevCzGbetS78+mIfAHQDzW3vekLCVDjvDQkFy/PTRNm5lp3ZzE8Es2uM5dnARFYRJoAwIQQ0RI4UVFMQwgQTwMS8yyo6bOiqgQkQCydNHesIm8rVuhYVanReigq11H4dEzAQ5nZlSpDovETlJalpAED+UInkakxBiuRqgqi0fnszIXZNxHq8dOdE7OZyCoA0NePTWdbmoro99AU3RedrAOANCx2OSO8U3W6POFaPPT/jKzY3M/iA75thhxdTyWLjr3T187nEgJ+7/iDZ62WCcTF1oIyvZLs9zI1A+gMX7VoXTpQrnU5q4C5nc9M3Fvj9mprYkz+ZZS9Oxfv97Hk39Yw/rCqGI5jtclLX7iXaHTFHMNsi76QP+33MZ/fYyz7mh8cZAFB1NBRIXvHHr82y12bjiT0ZAOa2C5em6S/muI+m6ZmwpUwIHClGWdJKknYgqZW61tBQXUWibCIlSStLmtQ0FB0dKXpJUkVZK8tapa4TAm1W7kgzsKrjpo5UA6vWs2bgpongN69UAzc11FCNhooUzVwmGQAi2epQIPn1w/RQIPmm7zQDff84M7LI31pO3VzmMwd1AFh8Xhy8zw0v8F/Ocff/LLQ8hznx7J3YJR/b5aS/CvClmvaq1Bjws7ZJpneaPeeinyYPZRXZV7NnJ2JXZ7n37DH76nFgW8lKt4ceXkz3+9jRJbNUz/jDwfuJj/3c4Hyyb5pZi4uJYmN8JXvBy9x6mLFN/qtUYVZsd0TPu+l2R2xkiX/TJAN+tstJ2SZpm4uirCZxbwinx6PdHubU7ejtlWPlYrW5SpdCnLjKlJ+/qhKrPbf5SogVNxNimC1XZA0AMgf1Lb7yd6a6layk9s3itSFM6qoZnXUuQEekpqAjxVBb+WMNYamJjhqGorXy1xGpqxhhYiq/LtXnd3YXnu/N7+wG4yVrE/OQnSwLMHc/QbAFWcOAFc/Yo9YYig2bwwADgPX9f1zHabvN+dLvY7/5Lf12ZKvO0YtT8Y4JamQxRfDbkGmh9t2j9I+/v/r2UWZ2q9Cy+D/I/wDKg7O/d7Nu8gAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Smart Wrapping layout" title="Smart Wrapping layout" src="/static/8d74d7163de2c05ab0412a78290d8ede/5e02b/Smart-Wrapping-layout-252x300.png" srcSet="/static/8d74d7163de2c05ab0412a78290d8ede/e9ff0/Smart-Wrapping-layout-252x300.png 180w,/static/8d74d7163de2c05ab0412a78290d8ede/5e02b/Smart-Wrapping-layout-252x300.png 252w" sizes="(max-width: 252px) 100vw, 252px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Major advantages with this approach is the obvious performance improvement and memory consumption reduction. Why? Because we maintained the <code>VirtualizingStackPanel</code> in our main <code>ListBox.ItemsPanel</code>!</p><p>To prove my point, I’ve created a <a href="/5e0660052531977c5336030668c51dd4/PedroLamas.SmartWrapListDemo.zip">small demonstration app</a> showing the result of using these two approaches with a list of 400 items.</p><p>Download the code, deploy it on a phone or emulator, then run each approach separately and exit the app after each run in order to check the peak memory usage.</p><p>You’ll notice a huge difference in loading times, but I can tell you that memory wise, it’s the difference between using 120MB or just 20MB! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Poll: What are your plans for #wp7dev]]></title>
            <link>https://www.pedrolamas.com/2014/03/15/poll-what-are-your-plans-for-wp7dev/</link>
            <guid>https://www.pedrolamas.com/2014/03/15/poll-what-are-your-plans-for-wp7dev/</guid>
            <pubDate>Sat, 15 Mar 2014 14:22:03 GMT</pubDate>
            <content:encoded><![CDATA[<p>As I am about to start adding Windows Phone “Blue” support to <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>, I’m planning to stopping the <abbr title="Windows Phone 7">WP7</abbr> support on the 3.x!</p><p>The upcoming 4.x would have <abbr title="Windows Phone 8">WP8</abbr> and <abbr title="Windows Phone">WP</abbr> Blue support, allowing for a more future prune implementation and dropping the NuGet packages from 9 to just 2 (the Background package as it stands today and a main one with all the rest).</p><p>To actually understand the position of the Windows Phone developers about <abbr title="Windows Phone 7">WP7</abbr> development, I started a poll that I now invite you to answer! :)</p><script type="text/javascript" charSet="utf-8" src="https://secure.polldaddy.com/p/7881681.js"></script><noscript><a href="https://polldaddy.com/poll/7881681/">What are your plans for #wp7dev</a></noscript>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Want to meet the Cimbalino Windows Phone Toolkit?]]></title>
            <link>https://www.pedrolamas.com/2014/02/25/want-to-meet-the-cimbalino-windows-phone-toolkit/</link>
            <guid>https://www.pedrolamas.com/2014/02/25/want-to-meet-the-cimbalino-windows-phone-toolkit/</guid>
            <pubDate>Tue, 25 Feb 2014 11:51:01 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/07fb6735c443543f47a2c326e63df0f6/Wales-and-West-Windows-Application-Group.png" alt="Want to meet the Cimbalino Windows Phone Toolkit?" class="webfeedsFeaturedVisual" /></p><p>The next W&amp;W WAG (Wales and West Windows Application Group) meeting will be help <strong>tomorrow, February 26th</strong>, at Nokia Bristol office, and will feature me talking about the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>, and the <a href="http://mikehole.com/">Mike Hole</a>, talking about Bluetooth and <abbr title="Near Field Communication">NFC</abbr> based communication.</p><p>The meeting will start at 18h30, you can find more details and register <a href="http://www.meetup.com/Wales-and-West-Windows-Applications-Group/events/162683312/">here</a>!</p><p>Hope to see you there! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disabling screenshot functionality in a Windows Phone app]]></title>
            <link>https://www.pedrolamas.com/2014/01/20/disabling-screenshot-functionality-in-a-windows-phone-app/</link>
            <guid>https://www.pedrolamas.com/2014/01/20/disabling-screenshot-functionality-in-a-windows-phone-app/</guid>
            <pubDate>Mon, 20 Jan 2014 09:58:31 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/457e6eba26e773189b538de6c6684af7/Disabling-screenshot-functionality-in-a-Windows-Phone-8-app-300x270.png" alt="Disabling screenshot functionality in a Windows Phone app" class="webfeedsFeaturedVisual" /></p><p><strong>Update:</strong> Kudos to Murat and Rudy Huyn for pointing me out on a missing <code>return;</code> that would cause the <code>NotSupportedException</code> to be raised all the time… I’ve fixed the code by inverting the <code>if</code> condition.</p><p><strong>Update 2:</strong> Just noticed that <strong>GDR2 is also supported</strong>, as the code below will also work in devices with it! :)</p><p>Windows Phone 8 made it possible to <a href="http://www.windowsphone.com/en-gb/how-to/wp8/photos/take-a-screenshot">take a screenshot</a> of your screen at any time, just by pressing the Windows and Power button at the same time.</p><p>Sure, this is a really cool feature and can be quite handy from time to time, but it can become a security concern for some specific scenarios, not to mention a way to copy someone else’s graphical designs!</p><p>Since Windows Phone 8 update 3 (GDR2) there is now a hidden feature that allows you to disable the Screenshot functionality on a page by page basis: the <code>PhoneApplicationPage.IsScreenCaptureEnabled</code>!</p><p>This is a hidden property that requires Reflection in order to access and modify it’s state. The following extension methods will help you with that:</p><pre><code class="language-csharp">public static class PhoneApplicationPageExtensionMethods
{
    public static bool CanSetScreenCaptureEnabled(this PhoneApplicationPage page)
    {
        return Environment.OSVersion.Version &gt;= new Version(8, 0, 10322);
    }

    public static void SetScreenCaptureEnabled(this PhoneApplicationPage page, bool enabled)
    {
        var propertyInfo = typeof(PhoneApplicationPage).GetProperty(&quot;IsScreenCaptureEnabled&quot;);

        if (propertyInfo == null)
        {
            throw new NotSupportedException(&quot;Not supported in this Windows Phone version!&quot;);
        }

        propertyInfo.SetValue(page, enabled);
    }

    public static bool GetScreenCaptureEnabled(this PhoneApplicationPage page)
    {
        var propertyInfo = typeof(PhoneApplicationPage).GetProperty(&quot;IsScreenCaptureEnabled&quot;);

        if (propertyInfo == null)
        {
            throw new NotSupportedException(&quot;Not supported in this Windows Phone version!&quot;);
        }

        return (bool)propertyInfo.GetValue(page);
    }
}
</code></pre><p>The first step is to call <code>CanSetScreenCaptureEnabled()</code> from inside your <code>PhoneApplicationPage</code> to check if the Windows Phone version is at least Windows Phone 8 update 3 (version 8.0.10322) as that is the minimum required version for this to work!</p><p>If it is, we can then use the <code>GetScreenCaptureEnabled()</code> and <code>SetScreenCaptureEnabled()</code> extension methods to change the property value!</p><p>Here is a sample usage code to disable screenshot functionality:</p><pre><code class="language-csharp">public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        if (this.CanSetScreenCaptureEnabled())
        {
            this.SetScreenCaptureEnabled(false);
        }
    }
}
</code></pre><p>If you do try to take a screenshot after that code, this is what will happen:</p><p><a href="/2b1163f816053f509641e93614774583/Application-screenshot-functionality-disabled.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:180px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:166.66666666666669%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAhCAIAAABWXBxEAAAACXBIWXMAAAsTAAALEwEAmpwYAAABEUlEQVQ4y+3Qy4qDMBQG4CRN04kYUFzUjUhrgjFqU5VCV5WUwmx8AduNq77/IwzoEGY6LmZb8FsEcnI5/AdgjOM4TtM0iiIhBOd8t9slSZKmqZQyiiLOeVmWnucBACCE4CcI4WazIYR8jAghlFJCyGq1whhPK8YYIQT+IoQopabvpZRZlmmtt9ut7WNXhNBrZwCAraIR+D9K6fF4lFKez+eiKJqmMcYwxg6Hg9a6qqrT6XS9Xuu6bts2CIJfycMw/Bw9n09jzOPxuN/vvu8LIW632zAMl8ulqqqu6/q+f33MGNvv99PM8jxXStnxrNdr13WnUAghx3HmQ9nMcDR7Ybb+fWA72PHarQUWi8Vi8c6+AKGYIHdZFwD3AAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Application screenshot functionality disabled" title="Application screenshot functionality disabled" src="/static/5d52be23dcec50439c7351f362c85f4b/e9ff0/Application-screenshot-functionality-disabled-180x300.png" srcSet="/static/5d52be23dcec50439c7351f362c85f4b/e9ff0/Application-screenshot-functionality-disabled-180x300.png 180w" sizes="(max-width: 180px) 100vw, 180px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>The same result will happen from the application switcher screen:</p><p><a href="/2beb3ed0c045139cc9e51a3f0c13b2f8/Task-switcher-screenshot-functionality-disabled.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:180px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:166.66666666666669%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAhCAIAAABWXBxEAAAACXBIWXMAAAsTAAALEwEAmpwYAAACIklEQVQ4y+2Vb2/SQBzHv1caoAgd/5opUGiv1zKXAQ6QKWZj6cJMzLInZskmRvdAB0j5t3fgTHzmI9+Aj33gW9RcIWQUWAwmPtrlk0vv8vv07np3v0IURS2n5i2WVdOWaZiMUj1nUC1vsa28qWZSjOqFne3ohgyAEIK5op6LesuncQLsvai/neDTWiJ1a7cp5N5APfcCcwhjwGEDGP3p87Tp1jPMoRfQDmh3inEHHTdyHhif1meuwcdvL0VgXWE6hVUy6xPregKsa5i30BzoAxjOUrnLP0n6NeQi5F3ORhnxKidW8Sl7evlMsY5F7cL1ux65A3NMki/CQSKHQ3JYkgLidC/dvT159fLD5YWkHsMYkgW5y2WlkUxspFKZh49S8UQiFHoQicjRWDwohTJqtlTcETZtsBGWyMZQUpvVctG2j2zbppQWCoV6vV6r1XbLZcA9W0oD5phv0sLII9/moV+E3x+Q5elhnJ1HQfD5CKAcctnwyJSvGcn9ySqxUAgReO968p3Tvpfv5b+VD9wwwQ31IGB2PJfLieezGzwJJ96RD1bcKuYg20KyyV8hVyBXEakg+hTxPZdniFWROQPre+8zMR2kL7XTnze/fiuN7/nmF3r0tXT6LbN/w1OHOcYEbi7JYT3oV8Enn+nJD8EaSdu94GNHLg0DW7z/VhpdlT1ZD9pHpN7xIK0NvY3cFfTOQvZflXqNHmHOukn/n/4Y/1P+A8wHCoty4CKcAAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Task switcher screenshot functionality disabled" title="Task switcher screenshot functionality disabled" src="/static/2023a2467936c0e15fd00af332f14f4a/e9ff0/Task-switcher-screenshot-functionality-disabled-180x300.png" srcSet="/static/2023a2467936c0e15fd00af332f14f4a/e9ff0/Task-switcher-screenshot-functionality-disabled-180x300.png 180w" sizes="(max-width: 180px) 100vw, 180px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Nowadays, privacy has become the #1 concern in everything we do, and I’m sure this is a really useful information for a bunch of apps out there (looking at you 6snap and all other Snapchat apps ;) )</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Windows Phone apps on my phone!]]></title>
            <link>https://www.pedrolamas.com/2013/12/30/the-windows-phone-apps-on-my-phone/</link>
            <guid>https://www.pedrolamas.com/2013/12/30/the-windows-phone-apps-on-my-phone/</guid>
            <pubDate>Mon, 30 Dec 2013 11:20:54 GMT</pubDate>
            <content:encoded><![CDATA[<p>So you got a brand new Windows Phone device for Christmas and still don’t know what to install on it?</p><p>Then look no further: here is the list of the best apps I have installed on my own phone! :)</p><h2>Social</h2><ul><li><a href="http://www.windowsphone.com/s?appid=0b792c7c-14dc-df11-a844-00237de2db9e">Twitter</a> - The fully featured Twitter app with multiple account support and push notifications that actually do work!</li><li><a href="http://www.windowsphone.com/s?appid=93da5d29-daf0-4783-9ed5-a87b33247ec6">Facebook Beta</a> - There is also a non-beta <a href="http://www.windowsphone.com/s?appid=82a23635-5bd9-df11-a844-00237de2db9e">Facebook</a> official app, but I prefer the beta one as it gives me the latest features sooner! ;)</li><li><a href="http://www.windowsphone.com/s?appid=c7d13b8d-9951-e011-854c-00237de2db9e">4th &amp; Mayor</a> - I know that there is an official <a href="http://www.windowsphone.com/s?appid=26cf3302-469f-e011-986b-78e7d1fa76f8">Foursquare</a> app and that it’s a lot better than the first version, but I still prefer 4th &amp; Mayor from Jeff Wilcox as it is quite simpler and uses a more direct approach!</li><li><a href="http://www.windowsphone.com/s?appid=218a0ebb-1585-4c7e-a9ec-054cf4569a79">WhatsApp</a> - free messaging that works on pretty much any phone? Yes, thank you very much! :)</li><li><a href="http://www.windowsphone.com/s?appid=c3f8e570-68b3-4d6a-bdbb-c0a3f4360a51">Skype</a> - The official Skype app, really good when it actually works… this is the one app I really need and sometimes fails me miserably :\</li><li><a href="http://www.windowsphone.com/s?appid=7d795cdf-fb1b-4bdf-8f5e-76eb19f7079e">6tag</a> - developed by Rudy Huyn, probably the best Instagram app for Windows Phone. There is an official <a href="http://www.windowsphone.com/s?appid=3222a126-7f20-4273-ab4a-161120b21aea">Instagram BETA</a> app, but it’s still lacking some features…</li><li><a href="http://www.windowsphone.com/s?appid=93c35e04-5d4d-42d2-aaaa-3bd1532443b2">Disqus</a> - It’s probably the most used network for commenting on forums and blogs everywhere!</li><li><a href="http://www.windowsphone.com/s?appid=bdc7ae24-9051-474c-a89a-2b18f58d1317">LinkedIn</a> - LinkedIn official app, to keep in eye on your professional connections.</li><li><a href="http://www.windowsphone.com/s?appid=3d051f9b-9e03-456f-b647-bea34fe7031c">Viber</a> - Another <abbr title="Voice Over IP">VOIP</abbr> app, quite known out there</li></ul><h2>Tools + Productivity</h2><ul><li><a href="http://www.windowsphone.com/s?appid=e7994dbc-2336-4950-91ba-ca22d653759b">Authenticator</a> - In a time where security and privacy are lacking more and more, using two-factor sign-in whenever possible does help a bit (Microsoft, Google, and other websites use this approach)</li><li><a href="http://www.windowsphone.com/s?appid=220bfbf2-ee02-496c-a656-651a6c0c6518">Google</a> - not that different than accessing <a href="http://www.google.com">www.google.com</a> with the browser, but nevertheless it’s the <strong>only</strong> app that Google has on Windows Phone…</li><li><a href="http://www.windowsphone.com/s?appid=134e363e-8811-44be-b1e3-d8a0c60d4692">Adobe Reader</a> - Official Adobe Reader app to open <abbr title="Portable Document Format">PDF</abbr> files on the phone. There is also a <a href="http://www.windowsphone.com/s?appid=8f6154d6-1b70-431a-a579-b6a43477e837"><abbr title="Portable Document Format">PDF</abbr> Reader</a> from Microsoft as a really good alternative.</li><li><a href="http://www.windowsphone.com/s?appid=5d7f992b-ee03-e011-9264-00237de2db9e">BoxFiles for Dropbox</a> - There are quite a few Dropbox apps right now for Windows Phone (none is official) and I personally like this one.</li><li><a href="http://www.windowsphone.com/s?appid=ad543082-80ec-45bb-aa02-ffe7f4182ba8">SkyDrive</a> - full featured official SkyDrive app from Microsoft.</li><li><a href="http://www.windowsphone.com/s?appid=c945c809-5e5d-4db3-b4c9-70c8cebd5235">GDrive</a> - Using Google Drive? Then this is what you need! It’s not a fully featured client, but at least it is better than nothing!</li><li><a href="http://www.windowsphone.com/s?appid=afadc741-961a-4677-b490-c1777bdfe9e5">TeamViewer</a> - Access your machine remotely using TeamViewer.</li></ul><h2>News + Weather</h2><ul><li><a href="http://www.windowsphone.com/s?appid=643381de-4724-e011-854c-00237de2db9e">Nextgen Reader</a> - this is the #1 app in my phone!!! I just couldn’t go by without reading my <abbr title="Really Simple Syndication">RSS</abbr> feeds, and given it uses <a href="http://www.feedly.com">Feedly</a> as source, all my feeds are synchronized; just perfect!!</li><li><a href="http://www.windowsphone.com/s?appid=c7ac43c5-5d99-4e65-913d-e92e253e9e99">Amazing Weather HD</a> - A really good weather app with nice look and quite a few features. A free alternative is <a href="http://www.windowsphone.com/s?appid=63c2a117-8604-44e7-8cef-df10be3a57c8">Bing Weather</a>, also quite nice!</li></ul><h2>Lifestyle / Shopping</h2><ul><li><a href="http://www.windowsphone.com/s?appid=351decc7-ea2f-e011-854c-00237de2db9e">Amazon Mobile</a> - Search Amazon, purchase stuff, check your order status…</li><li><a href="http://www.windowsphone.com/s?appid=92d3a3a3-66d9-df11-a844-00237de2db9e">eBay</a> - The app is quite simple and could use a better look, but it works well and does a proper job alerting when auctions are about to end.</li></ul><h2>Travel + Navigation</h2><ul><li><a href="http://www.windowsphone.com/s?appid=7ca9cfea-1b92-4ca4-8559-269936d5361e">Geosense</a> - quite useful to convert from different GPS coordinates types, to get my location, open KML files from Google Earth… and yes, <strong>I wrote it</strong> and that’s also another reason why it’s here, so sue me! :P</li><li><a href="http://www.windowsphone.com/s?appid=180b0f46-e753-e011-854c-00237de2db9e">TripAdvisor</a> - I always like to read the reviews on hotels and restaurants on TripAdvisor before I actually go to the place.</li><li><a href="http://www.windowsphone.com/s?appid=dc5f12fa-b49d-e011-986b-78e7d1fa76f8">Currency</a> - Currency exchange, provided by <a href="http://www.xe.com/">XE</a></li></ul><h2>Entertainment</h2><ul><li><a href="http://www.windowsphone.com/s?appid=ff971299-eed8-df11-a844-00237de2db9e">IMDb</a> - The official IMDb app for Windows Phone, probably the best showcase for a <abbr title="Windows Phone">WP</abbr> app and the best IMDb client you’ll find in any mobile device!</li><li><a href="http://www.windowsphone.com/s?appid=da4c75d6-df50-e011-854c-00237de2db9e">Helium Voice Free</a> - Because it’s fun and I like to show kids! :)</li></ul><h2>Business</h2><ul><li><a href="http://www.windowsphone.com/s?appid=01f53e5a-7870-49cb-8afc-d6fab6d7a3cd">Office Remote</a> - do you do PowerPoint presentations? Then do yourself a favor and install this in your Windows Phone!</li></ul><h2>Personal Finance</h2><ul><li><a href="http://www.windowsphone.com/s?appid=75738196-1db2-49d9-afb1-d66a34d19fb6">PayPal</a> - I like to keep a close eye on my PayPal transactions!</li></ul><h2>Photo</h2><ul><li><a href="http://www.windowsphone.com/s?appid=5db119bf-7ad5-df11-a844-00237de2db9e">Pictures Lab</a> - Nice, clean, and fast, picture effects app, developed by René Schulte.</li><li><a href="http://www.windowsphone.com/s?appid=4b113087-6abc-40fb-8e49-d02adeba1393">Tile Me!</a> - Create a Windows Phone tile picture with this app, and use it everywhere! :D</li></ul><h2>Music + Video</h2><ul><li><a href="http://www.windowsphone.com/s?appid=dcbb1ac6-a89a-df11-a490-00237de2db9e">YouTube</a> - a couple a months ago there was an official YouTube app (and it was really good, I might add), but Google pulled the plug on it and so we are stuck with just this miserable plugin and YouTube mobile website…</li><li><a href="http://www.windowsphone.com/s?appid=2f8d5271-2b81-e011-986b-78e7d1fa76f8">Shazam</a> - You know when you’re in a party, listening to a music that you actually like and don’t know who the artist is? That’s when Shazam comes quite handy!</li><li><a href="http://www.windowsphone.com/s?appid=b3690063-6d30-43aa-9934-84a99781fa34">Sax</a> - A simple fun way of playing saxophone without one!</li></ul><h2>Books + Reference</h2><ul><li><a href="http://www.windowsphone.com/s?appid=fd40c569-2681-48df-9ff3-53ffd80aa9b5">Wikipedia</a> - it’s Wikipedia, and that is all anyone needs for reference…</li></ul><p>So go on now, install some apps in your phone and have fun!</p><p>And by the way: Happy New Year!!! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating PNG image files in Windows Phone]]></title>
            <link>https://www.pedrolamas.com/2013/12/05/creating-png-image-files-in-windows-phone/</link>
            <guid>https://www.pedrolamas.com/2013/12/05/creating-png-image-files-in-windows-phone/</guid>
            <pubDate>Thu, 05 Dec 2013 13:04:46 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/0700b629d76c8cc8f128c5fae4c0e89a/PNG-image-files-in-Windows-Phone.png" alt="Creating PNG image files in Windows Phone" class="webfeedsFeaturedVisual" /></p><p>Windows Phone image processing and format support has always been lacking a bit, especially when compared with all the <abbr title="Graphics Device Interface">GDI</abbr>+ capabilities one has available in the full .NET Framework.</p><p>For instance, you can read <abbr title="Joint Photographic Experts Group">JPEG</abbr> and <abbr title="Portable Network Graphics">PNG</abbr> files, but you can only save to <abbr title="Joint Photographic Experts Group">JPEG</abbr>, as there is no support to save to <abbr title="Portable Network Graphics">PNG</abbr> directly on the platform.</p><p>Saving to <abbr title="Portable Network Graphics">PNG</abbr> has been quite easy since the beginning of Windows Phone 7 by using 3rd party libraries, and on this chapter, <a href="http://imagetools.codeplex.com/">.NET Image Tools</a> is the most used one!</p><p>But personally, using Image Tools always presented two major problems:</p><ul><li>it requires <a href="http://www.icsharpcode.net/opensource/sharpziplib/">SharpZipLib</a> (a GPL licensed library) to handle Zlib compression</li><li>it’s quite slow and uses a lot of memory</li></ul><p>The first problem is a definitive “no-no” for usage in closed code commercial apps, as <a href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL</a> is ”<a href="http://en.wikipedia.org/wiki/Viral_license">viral license</a>”</p><p>The second problem is more related to the way Image Tools was developed, not considering usage in mobile devices that have lower specifications as to processor capacity or memory.</p><h2>The Cimbalino Windows Phone Toolkit way</h2><p><a href="http://cimbalino.org/">Cimbalino Windows Phone Toolkit</a> version 3.2.0 presents a new <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit.Background%20%28WP71%29/Extensions/WriteableBitmapExtensions.cs"><strong>WriteableBitmapExtensions</strong></a> containing a <code>SavePng()</code> method to create <abbr title="Portable Network Graphics">PNG</abbr> files from <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.media.imaging.writeablebitmap%28v=vs.105%29.aspx">WriteableBitmap</a> instances!</p><p>Internally it uses DotNetZip (Ms-Pl license) to handle the required ZLib compression and it’s quite optimized for speed and low memory consumption.</p><p>To illustrate the speed improvement, <a href="https://twitter.com/ErtaySh">Ertay Shashko</a> was kind enough to test it with his <a href="http://www.windowsphone.com/s?appid=4b113087-6abc-40fb-8e49-d02adeba1393">Tile Me</a> app, and here are the results of his personal usage:</p><blockquote class="twitter-tweet"><p lang="en" dir="ltr"><a href="https://twitter.com/pedrolamas?ref_src=twsrc%5Etfw">@pedrolamas</a> Imagetools (~2.5 seconds to generate): <a href="http://t.co/LS5Lj1ZSCq">http://t.co/LS5Lj1ZSCq</a> Cimbalino (Default, ~0.7 secs to gener.): <a href="http://t.co/Hv0CAOK8K6">http://t.co/Hv0CAOK8K6</a></p>— Ertay Shashko (@ErtaySh) <a href="https://twitter.com/ErtaySh/status/398103937360089089?ref_src=twsrc%5Etfw">November 6, 2013</a></blockquote> <script async="" src="https://platform.twitter.com/widgets.js" charSet="utf-8"></script><p>I guess the numbers speak for themselves! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handle 1080p in Windows Phone like a Pro!]]></title>
            <link>https://www.pedrolamas.com/2013/11/06/handle-1080p-in-windows-phone-like-a-pro/</link>
            <guid>https://www.pedrolamas.com/2013/11/06/handle-1080p-in-windows-phone-like-a-pro/</guid>
            <pubDate>Wed, 06 Nov 2013 11:06:53 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/3db89adb85e654d5a0970f6a93f1e1c1/WP8-device-running-at-1080p-300x270.png" alt="Handle 1080p in Windows Phone like a Pro!" class="webfeedsFeaturedVisual" /></p><p>The change log for <a href="http://blogs.windows.com/windows_phone/b/windowsphone/archive/2013/10/14/announcing-our-third-windows-phone-8-update-plus-a-new-developer-preview-program.aspx">Windows Phone 8 update 3</a> (also known as GDR3) has been known for a few weeks and one of the new features is the added</p><blockquote><p>support for bigger, higher-resolution screens</p></blockquote><p>This is obviously only for new devices, with 5” or 6” screens using 1080p resolution, like the amazing <a href="http://www.nokia.com/global/products/phone/lumia1520/">Nokia Lumia 1520</a>!</p><p>Here’s the complete list of Windows Phone supported resolutions, divided by aspect ratio:</p><ul><li><em>15:9</em><ul><li><strong><abbr title="Wide Video Graphics Array">WVGA</abbr></strong> <em>(480x800, 1.0x scale factor)</em> - this is the only resolution available in <abbr title="Windows Phone 7">WP7</abbr></li><li><strong><abbr title="Wide Extended Graphics Array">WXGA</abbr></strong> <em>(768x1280, 1.6x scale factor)</em></li></ul></li><li><em>16:9</em><ul><li><strong>720p</strong> <em>(720x1280, 1.5x scale factor)</em></li><li><strong>1080p</strong> <em>(1080x1920, 2.25x scale factor)</em> - only supported in the new large screen devices with <abbr title="Windows Phone 8">WP8</abbr> update 3</li></ul></li></ul><p>As a Windows Phone developer/designer, <strong>you don’t need to know this!</strong></p><p>All you need to do is design the interface in <abbr title="Extensible Application Markup Language">XAML</abbr> for the 480x800 resolution, and it will automatically scale up using a fixed scale factor! How cool is that? :)</p><p>Now if you really want to know what is the device scale factor (maybe to create different app resolution-aware layouts), you can read the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.interop.content.scalefactor%28v=vs.105%29.aspx">Application.Current.Host.Content.ScaleFactor</a> (note: this property will return the scale factor * 100).</p><p>But there’s a catch: for the new 1080p devices, the scale factor is returned as 1.5x, just as the 720p devices, instead of the correct 2.25x…</p><p>To get the real scale factor, you can use the following code snippet:</p><pre><code class="language-csharp">public int ScaleFactor
{
    get
    {
        object physicalScreenResolutionObject;

        if (DeviceExtendedProperties.TryGetValue(&quot;PhysicalScreenResolution&quot;, out physicalScreenResolutionObject))
        {
            var physicalScreenResolution = (Size)physicalScreenResolutionObject;

            return (int)(physicalScreenResolution.Width / 4.8);
        }

        return Application.Current.Host.Content.ScaleFactor;
    }
}
</code></pre><p>In <abbr title="Windows Phone 8">WP8</abbr> update 3 you can use <code>DeviceExtendedProperties.TryGetValue(&quot;PhysicalScreenResolution&quot;, out physicalScreenResolutionObject)</code> to retrieve the screen <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.size%28v=vs.105%29.aspx">Size</a> resolution in pixels, take the <code>Width</code> of it and divide it by 4.8 to know the correct scale factor.</p><p>If the call to <code>DeviceExtendedProperties.TryGetValue</code> fails it just means you don’t have a <abbr title="Windows Phone 8">WP8</abbr> GDR3 device, and as such the device is not a 1080p device and you can just fallback to use the <code>Application.Current.Host.Content.ScaleFactor</code> approach!</p><h2>The Cimbalino Windows Phone Toolkit way</h2><p>Previous versions of <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a> already had the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit.Background%20%28WP71%29/Services/IScreenInfoService.cs"><strong>IScreenInfoService</strong></a> to help handling this, and since version 3.2.0, you can also count on the <strong>added 1080p support!</strong> :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit Updated to v3.2.0]]></title>
            <link>https://www.pedrolamas.com/2013/11/04/cimbalino-windows-phone-toolkit-updated-to-v3-2-0/</link>
            <guid>https://www.pedrolamas.com/2013/11/04/cimbalino-windows-phone-toolkit-updated-to-v3-2-0/</guid>
            <pubDate>Mon, 04 Nov 2013 11:54:43 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/58e959564fc7425d90e4f09137e0baa2/Cimbalino-Windows-Phone-Toolkit-300x270.png" alt="Cimbalino Windows Phone Toolkit Updated to v3.2.0" class="webfeedsFeaturedVisual" /></p><p>Version 3.2.0 of <a href="http://cimbalino.org"><strong>Cimbalino Windows Phone Toolkit</strong></a> is now available!</p><p>This release is mostly a bug/performance fix; here’s the change log:</p><ul><li>Added the <strong>WriteableBitmapExtensions</strong>, which provides a high-performance &amp; low memory impact <code>SavePng()</code> method!</li><li>Improved the <code>IScreenInfoService</code> and <code>ResolutionAwareUriConverter</code> to contemplate 1080p screens</li><li>The usual improvements and bug fixes</li></ul>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Phone Week]]></title>
            <link>https://www.pedrolamas.com/2013/09/18/windows-phone-week/</link>
            <guid>https://www.pedrolamas.com/2013/09/18/windows-phone-week/</guid>
            <pubDate>Wed, 18 Sep 2013 10:21:13 GMT</pubDate>
            <content:encoded><![CDATA[<p><a href="https://wpcommunityweek.eventday.com/"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:700px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:20.555555555555554%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA/0lEQVQI1wH0AAv/AAGo4gGf2ACZ1ACn4QCUzgCg2gCi3QCi3QGk3QGUzwGg2gKk3gCh2wqp4Ru56xq46x+67DzG7wuy6ACr5wAAdbsAT5YQVpoiXJ4jT5ImVZcpXJ0cZqYEUJUFWJwBW6ACVpwAUJggdLGLzOt9xOaJyemUzuoonNgAhc8AIGi2XovDY3y0VG2oWnStcoW5aH27fYzMS3W8EGG2JnC+L3bBLXbBKXTALnfCK3TALXbCK3XBJG+9GGa5AEFYr2JywUthsCZGlitMnDJSoC5QoVhpvGZyxEFWrjRJoTpNpEdZqUBSpj1QpTlMoztOpDZKoiU7miM6mWuSbqquY9t6AAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Windows Phone Week" title="Windows Phone Week" src="/static/dc06d9e3d7bc91b14ebd4cf7caced040/8c557/Windows-Phone-Week.png" srcSet="/static/dc06d9e3d7bc91b14ebd4cf7caced040/e9ff0/Windows-Phone-Week.png 180w,/static/dc06d9e3d7bc91b14ebd4cf7caced040/f21e7/Windows-Phone-Week.png 360w,/static/dc06d9e3d7bc91b14ebd4cf7caced040/8c557/Windows-Phone-Week.png 700w" sizes="(max-width: 700px) 100vw, 700px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>Directly from the <a href="https://wpcommunityweek.eventday.com/">official site</a>:</p><blockquote><p>Windows Phone Week is a series of events created for the developer community by Windows Phone Developer MVPs.</p><p>The events are in nine countries, encouraging developers from around the world to explore app and gaming development.</p><p>Each event has a unique agenda, format and registration process so please check the details at the location nearest you.</p></blockquote><p>Although at this stage only 9 countries are participating, there are plans to expand to other territories, so stay tuned! ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Phone URI association deep links and the ampersand]]></title>
            <link>https://www.pedrolamas.com/2013/09/11/windows-phone-uri-association-deep-links-and-the-ampersand/</link>
            <guid>https://www.pedrolamas.com/2013/09/11/windows-phone-uri-association-deep-links-and-the-ampersand/</guid>
            <pubDate>Wed, 11 Sep 2013 18:02:08 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/3a032a8ed59a738b7f32c71b49c0652e/hyperlink_hand.png" alt="Windows Phone URI association deep links and the ampersand" class="webfeedsFeaturedVisual" /></p><p>A few weeks ago I stumbled on an issue while using ampersand (<code>&amp;</code>) in a <abbr title="Uniform Resource Identifier">URI</abbr> association deep link with query string parameters!</p><p>Let’s start by assuming I have a <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206987%28v=vs.105%29.aspx#BKMK_URIassociations">Windows Phone app capable of handling deep links</a> with “my-app:” moniker. Now take a look at the following sample link:</p><pre><code class="language-text">my-app://do/stuff/?param1=a%26b&amp;param2=c
</code></pre><p>We can easily see a query string with two parameters, and after decoding their values, we get <code>param1 = &quot;a&amp;b&quot;</code> and <code>param2 = &quot;c&quot;</code>.</p><p>If we use the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh701480.aspx">Launcher.LaunchUriAsync(uri)</a> method to open the link, this is what will arrive in the internal UriMapper:</p><pre><code class="language-text">/Protocol?encodedLaunchUri=my-app%3A%2F%2Fdo%2Fstuff%2F%3Fparam1%3Da%2526b%26param2%3Dc
</code></pre><p>By retrieving and decoding the <code>encodedLaunchUri</code> from the previous link, the result will be <code>&quot;my-app://do/stuff/?param1=a%26b&amp;param2=c&quot;</code>, matching the original uri, as we would expect!</p><p>If we now use a web page with that link on it instead, open the page inside Internet Explorer on the phone and tap on the link, this is what will get to the app UriMapper:</p><pre><code class="language-text">/Protocol?encodedLaunchUri=my-app%3A%2F%2Fdo%2Fstuff%2F%3Fparam1%3Da%26b%26param2%3Dc
</code></pre><p>If we do as before and retrieve and decode the <code>encodedLaunchUri</code>, we will get <code>&quot;my-app://do/stuff/?param1=a&amp;b&amp;param2=c&quot;</code>, which in this case, <strong>doesn’t match the original deep link!</strong></p><p>This behavior is due to Internet Explorer in Windows Phone, as it seems to decode all links before trying to navigate to them, and when it can’t perform the navigation (e.g. when the link isn’t a http:// or https:// link) it just sends it to the platform to handle it, but by that time <strong>the link has already been wrongly re-encoded</strong>!</p><p>So far I haven’t been able to find any way of bypassing this issue, apart of simply not using the <code>&amp;</code> in my apps deep links… and my advice to you is to proceed just like this!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit: AutoFocusBehavior]]></title>
            <link>https://www.pedrolamas.com/2013/08/19/cimbalino-windows-phone-toolkit-autofocusbehavior/</link>
            <guid>https://www.pedrolamas.com/2013/08/19/cimbalino-windows-phone-toolkit-autofocusbehavior/</guid>
            <pubDate>Mon, 19 Aug 2013 12:33:58 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/2fb559325337b3d7f3a3950ac2750bdd/Keyboard-Tab-Key-300x270.png" alt="Cimbalino Windows Phone Toolkit: AutoFocusBehavior" class="webfeedsFeaturedVisual" /></p><p>Most desktop applications use the Tab key to jump focus from one control to the next one, and this is expected behavior and common knowledge to most users.</p><p>On Android, the on-screen keyboard normally shows a “Next” key to - yes, you’ve guessed it! - go to the next field, and that is something really useful when filling long forms!</p><p>In truth, some native Windows Phone apps actually do this on some fields, where tapping the Enter key will have the same result, but unfortunately this is not the default behavior.</p><p>You could simulate this behavior using the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.textbox.onkeyup%28v=vs.105%29.aspx">TextBox.KeyUp</a> or <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.textbox.onkeydown%28v=vs.105%29.aspx">TextBox.KeyDown</a> events, and then calling <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.control.focus(v=vs.105).aspx">Control.Focus()</a> on the next control you want to get focus, but I guess we can all agree that this is quite some work and if you change the fields order, you’d have to change the code accordingly.</p><h2>The Cimbalino Windows Phone Toolkit way</h2><p>Well, as of <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a> version 3.1.0, all you need to do is add the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit%20(WP71)/Behaviors/AutoFocusBehavior.cs"><strong>AutoFocusBehavior</strong></a> to your Page and… relax! :)</p><p>Yes, that’s really all it takes, as the behavior contains the everything needed to manage TextBox/PasswordBox control focus changes on Enter key, with some added bonus:</p><ul><li><code>TabIndex</code> property value from controls will be taken into account and the order will be respected</li><li>Any control with <code>IsEnabled = false</code>, <code>Visibility = Collapsed</code>, or <code>TabStop = false</code> will be skipped</li><li>Any <code>TextBox</code> control with <code>AcceptsEnter = true</code> will just use the default expected behavior (tapping Enter will just add a new line)</li><li>The <code>AutoFocusBehavior.CycleNavigation</code> property controls whether focus will jump from last control to first one or just focus the full page</li><li>The <code>AutoFocusBehavior.SelectAllOnFocus</code> property controls whether the entire contents of a control will be selected on focus</li></ul><p>There is also an <code>AfterAutoFocus</code> event and <code>AfterAutoFocusCommand</code> so you can easily add some extra behavior of yours to the current one! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit Updated to v3.1.0]]></title>
            <link>https://www.pedrolamas.com/2013/08/15/cimbalino-windows-phone-toolkit-updated-to-v3-1-0/</link>
            <guid>https://www.pedrolamas.com/2013/08/15/cimbalino-windows-phone-toolkit-updated-to-v3-1-0/</guid>
            <pubDate>Thu, 15 Aug 2013 10:47:52 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/58e959564fc7425d90e4f09137e0baa2/Cimbalino-Windows-Phone-Toolkit-300x270.png" alt="Cimbalino Windows Phone Toolkit Updated to v3.1.0" class="webfeedsFeaturedVisual" /></p><p>Version 3.1.0 of <a href="http://cimbalino.org"><strong>Cimbalino Windows Phone Toolkit</strong></a> is now available!</p><p>Here’s the change-log for this release:</p><ul><li>New <strong>MarketplaceInformationService</strong> (<a href="/2013/07/24/checking-for-updates-from-inside-a-windows-phone-app/">more info</a>)</li><li>New <strong>MediaLibraryService</strong></li><li>New <strong>FMRadioService</strong></li><li>New <strong>LockScreenService</strong></li><li>New <strong>AutoFocusBehavior</strong> (<a href="/2013/08/19/cimbalino-windows-phone-toolkit-autofocusbehavior/">more info</a>)</li><li>Various improvements and bug fixes</li></ul><p>You can count on some articles around the new stuff for the next few days! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FMRadio vs. BackgroundAudioPlayer... fight!!]]></title>
            <link>https://www.pedrolamas.com/2013/08/12/fmradio-vs-backgroundaudioplayer-fight/</link>
            <guid>https://www.pedrolamas.com/2013/08/12/fmradio-vs-backgroundaudioplayer-fight/</guid>
            <pubDate>Mon, 12 Aug 2013 10:00:47 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/563f774e0af0883e8175342e40edf9b9/Windows-Phone-8-FM-Radio-604x270.png" alt="FMRadio vs. BackgroundAudioPlayer... fight!!" class="webfeedsFeaturedVisual" /></p><h2>“The cat is out of the bag”…</h2><p>…as <a href="http://www.windowsphone.com/en-gb/how-to/wp8/basics/windows-phone-8-update-history">Microsoft has confirmed</a> that <strong>FM Radio is making a return in the next update to Windows Phone 8</strong> (commonly known as GDR2)!</p><p>Obviously, updating your phone to GDR2 may not suffice, as the phone itself must have FM Radio tuning capability from factory!</p><p>Back when Windows Phone 7.x was king we could use the <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.devices.radio.fmradio%28v=vs.105%29.aspx">FMRadio</a> class to control the device FM Radio, but given that no support for it was added to Windows Phone 8, accessing it in a <abbr title="Windows Phone 8">WP8</abbr> device would just throw an exception… but that was <em>before</em> GDR2!</p><p><a href="http://mark.mymonster.nl">Mark Monster</a>, Silverlight <abbr title="Most Valuable Professional">MVP</abbr>, has written a really good <a href="http://mark.mymonster.nl/2013/08/09/fmradio-will-be-back-in-windows-phone-8-gdr2-use-it-with-care">article</a> on how to safely use the <code>FMRadio</code> class across all versions of Windows Phone.</p><h2>So what’s the problem?</h2><p>Here’s the whole problem and how you can check it, step by step:</p><ul><li><strong>Preconditions</strong><ul><li>Use a real phone with Windows Phone updated to GDR2</li><li>Plug in your headphones to the phone (the phone uses them as an FM Radio antenna)</li></ul></li><li><strong>Steps to reproduce</strong><ul><li>Open Music+Videos hub</li><li>Tap the “radio” item to start the FM Radio tuner</li><li>Tune in a radio station and check that you can hear audio on the headphones</li><li>Open any app that uses the <code>BackgroundAudioPlayer</code> and start playback</li></ul></li><li><strong>Actual Results</strong><ul><li>You hear the FM Radio audio and the audio from the app… at the same time!!</li></ul></li><li><strong>Expected Results</strong><ul><li>FM Radio should stop and you should now be hearing the audio from the app</li></ul></li></ul><p>Basically, there seems to be some sort of issue where the FM Radio does not stop once the <code>BackgroundAudioPlayer</code> starts!</p><p>You can however easily bypass this issue: just ensure you stop the FM Radio playback <strong>before</strong> starting the <code>BackgroundAudioPlayer</code> or any other playback for that matter!</p><p>To make things easier, you can use the following code snippet:</p><pre><code class="language-csharp">using Microsoft.Devices.Radio;

public class FMRadioSafe
{
    private static bool? _isAvailable;

    public static bool IsAvailable
    {
        get
        {
            if (!_isAvailable.HasValue)
            {
                try
                {
                    _isAvailable = FMRadio.Instance != null;
                }
                catch
                {
                    _isAvailable = false;
                }
            }

            return _isAvailable.Value;
        }
    }

    public static void Stop()
    {
        if (IsAvailable)
        {
            FMRadio.Instance.PowerMode = RadioPowerMode.Off;
        }
    }
}
</code></pre><p>Just copy and past this to your app and call <code>FMRadioSafe.Stop()</code> before any audio output instruction and you’re done! :)</p><p><strong>Update 20/08/2013:</strong> You can now use the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit.MediaLibrary%20%28WP71%29/Services/FMRadioService.cs"><strong>FMRadioService</strong></a> from <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a> version 3.0.0!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Checking for updates from inside a Windows Phone app]]></title>
            <link>https://www.pedrolamas.com/2013/07/24/checking-for-updates-from-inside-a-windows-phone-app/</link>
            <guid>https://www.pedrolamas.com/2013/07/24/checking-for-updates-from-inside-a-windows-phone-app/</guid>
            <pubDate>Wed, 24 Jul 2013 16:42:14 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/ef6e41166e7b09fa2471e5163ddb0c3e/Store-tile-with-1-update.png" alt="Checking for updates from inside a Windows Phone app" class="webfeedsFeaturedVisual" /></p><p>A few months ago, I started receiving some crash reports from one of my most successful apps, <a href="http://windowsphone.com/s?appid=7ca9cfea-1b92-4ca4-8559-269936d5361e">Geosense</a>!</p><p>After fixing the issue and publishing an updated version of the app, until today I still get quite a few reports from the very same old version, but none from the updated one!</p><p>This has got me to think on the reason to why people don’t update their apps! Here are some reasons:</p><ul><li>No constant internet connection</li><li>Removing the Store tile from the Home screen</li><li>Don’t care about updating apps!</li></ul><p>The first one doesn’t make much sense to me, as the Windows Phone ecosystem makes a lot more sense as a “always online” system! Also, Geosense requires internet connection to work and crash reports can’t be done without internet connection, so this doesn’t seem to be the main reason in my case!</p><p>I don’t see the point in it, but not caring to check and update the apps in ones phone is just a matter of personal opinion!</p><p>That leaves the middle option: having the Store tile in the Home screen will enable users to get visual notification of updates (the number of updated apps appears in the tile); without it, the only other option is that the user actually opens the Store app from the applications menu.</p><p>Wouldn’t it be nice to just get the app to notify the user that an update is available?</p><p>Keeping this in mind, I opened Fiddler on my laptop, set my phone to use it as a proxy server, opened Geosense info from the store, and this is the request I could see going to Microsoft servers:</p><pre><code class="language-text">http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/7ca9cfea-1b92-4ca4-8559-269936d5361e?os=8.0.9903.0&amp;cc=GB&amp;oc=&amp;lang=en-GB&amp;hw=520170499&amp;dm=RM-821_eu_euro1&amp;oemId=NOKIA&amp;moId=VOD-GB&amp;cf=99-1
</code></pre><p>I can see in the above url the application ProductId (7ca9cfea-1b92-4ca4-8559-269936d5361e) the windows phone version (os=8.0.9903.0), the store territory (cc=GB), the language (lang=en-GB) and a bunch of other stuff related to the device brand, model and version.</p><p>The response is even more interesting, as it shows all the Store information about the app, including the latest available version and release date.</p><p>Given we are only interested in the version, after manually clearing up the response this is what we get:</p><pre><code class="language-xml">&lt;a:feed xmlns:a=&quot;http://www.w3.org/2005/Atom&quot; xmlns:os=&quot;http://a9.com/-/spec/opensearch/1.1/&quot; xmlns=&quot;http://schemas.zune.net/catalog/apps/2008/02&quot;&gt;
  &lt;!-- other stuff --&gt;

  &lt;a:entry&gt;
    &lt;!-- other stuff --&gt;

    &lt;version&gt;1.10.1.8&lt;/version&gt;

    &lt;!-- other stuff --&gt;
  &lt;/a:entry&gt;

  &lt;!-- other stuff --&gt;
&lt;/a:feed&gt;
</code></pre><p>Well, we now know how to get the Store information about a particular app, we know what gets returned and how to read it, so let’s put that all together!</p><p>We will need the ProductID for the current running app, and for that we can just read it from the WMAppManifest.xml file like I shown in a <a href="http://code.msdn.microsoft.com/Generating-a-Windows-Phone-9d19f939">previous article</a>:</p><pre><code class="language-csharp">public static string GetManifestAttributeValue(string attributeName)
{
    var xmlReaderSettings = new XmlReaderSettings
    {
        XmlResolver = new XmlXapResolver()
    };

    using (var xmlReader = XmlReader.Create(&quot;WMAppManifest.xml&quot;, xmlReaderSettings))
    {
        xmlReader.ReadToDescendant(&quot;App&quot;);

        return xmlReader.GetAttribute(attributeName);
    }
}
</code></pre><p>Given that there is no way in the current <abbr title="Software Development Kit">SDK</abbr> to retrieve the Store territory, we will fallback to the <code>CultureInfo.CurrentUICulture</code> value for it and also for the language.</p><p>Here’s the complete async method to retrieve the latest version information from the Store:</p><pre><code class="language-csharp">private Task&lt;Version&gt; GetUpdatedVersion()
{
    var cultureInfoName = CultureInfo.CurrentUICulture.Name;

    var url = string.Format(&quot;http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/{0}?os={1}&amp;cc={2}&amp;oc=&amp;lang={3}​&quot;,
        GetManifestAttributeValue(&quot;ProductID&quot;),
        Environment.OSVersion.Version,
        cultureInfoName.Substring(cultureInfoName.Length - 2).ToUpperInvariant(),
        cultureInfoName);

    var request = WebRequest.Create(url);

    return Task.Factory.FromAsync(request.BeginGetResponse, result =&gt;
    {
        var response = (HttpWebResponse)request.EndGetResponse(result);

        if (response.StatusCode != HttpStatusCode.OK)
        {
            throw new WebException(&quot;Http Error: &quot; + response.StatusCode);
        }

        using (var outputStream = response.GetResponseStream())
        {
            using (var reader = XmlReader.Create(outputStream))
            {
                reader.MoveToContent();

                var aNamespace = reader.LookupNamespace(&quot;a&quot;);

                reader.ReadToFollowing(&quot;entry&quot;, aNamespace);

                reader.ReadToDescendant(&quot;version&quot;);

                return new Version(reader.ReadElementContentAsString());
            }
        }
    }, null);
}
</code></pre><p>All you now have to do is compare it to the active app version, like in this sample code:</p><pre><code class="language-csharp">private async void CheckForUpdatedVersion()
{
    var currentVersion = new Version(GetManifestAttributeValue(&quot;Version&quot;));
    var updatedVersion = await GetUpdatedVersion();

    if (updatedVersion &gt; currentVersion
        &amp;&amp; MessageBox.Show(&quot;Do you want to install the new version now?&quot;, &quot;Update Available&quot;, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
    {
        new MarketplaceDetailTask().Show();
    }
}
</code></pre><p>At startup, just call <code>CheckForUpdatedVersion()</code> and it will check if a new version is available, and if so, show a confirmation message box to the user and open the Marketplace details for the updated app.</p><p>If you’re using <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>, I’ve added the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit.Background%20%28WP71%29/Services/IMarketplaceInformationService.cs"><strong>IMarketplaceInformationService</strong></a> that contains all the above logic to retrieve Store information for apps, with added bonus that will work not only for <abbr title="Windows Phone 8">WP8</abbr> but also in <abbr title="Windows Phone 7">WP7</abbr>!</p><p>For the time being, this new service is only available in the <strong>3.1.0-rc</strong> version of the toolkit, so make sure to install the pre-release version!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Phone Developer account for $19 USD]]></title>
            <link>https://www.pedrolamas.com/2013/06/27/windows-phone-developer-account-for-19-usd/</link>
            <guid>https://www.pedrolamas.com/2013/06/27/windows-phone-developer-account-for-19-usd/</guid>
            <pubDate>Thu, 27 Jun 2013 21:46:58 GMT</pubDate>
            <content:encoded><![CDATA[<p>You’ve been playing with Visual Studio Express for a while, creating some new cool apps and games for Windows Phone, and now you want to publish them but the \$99 USD price tag on the developer account seems a bit steep!</p><p>Well, how does \$19 USD sound like? :)</p><p>Until the end of August, that’s the current subscrition fee for a one year WPDev account (plus taxes)!</p><p>And in case you already have an account, <strong>you can renew your current account for the same price</strong>, as Joe Belfiore himself stated in a tweet just minutes ago!</p><blockquote class="twitter-tweet" data-conversation="none"><p>For those of you asking... If you&#x27;re already a dev you CAN renew at the $19 price! <a href="https://twitter.com/TheRomit">@TheRomit</a> <a href="https://twitter.com/mrcfield">@mrcfield</a></p>— joebelfiore (@joebelfiore) <a href="https://twitter.com/joebelfiore/statuses/350342740321644544">June 27, 2013</a></blockquote><script async="" src="//platform.twitter.com/widgets.js" charSet="utf-8"></script><p>Please check the <a href="https://dev.windowsphone.com/en-us/join">Windows Phone Dev Center</a> for more information!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The AbandonedMutexException hoax!]]></title>
            <link>https://www.pedrolamas.com/2013/06/14/the-abandonedmutexexception-hoax/</link>
            <guid>https://www.pedrolamas.com/2013/06/14/the-abandonedmutexexception-hoax/</guid>
            <pubDate>Fri, 14 Jun 2013 17:28:27 GMT</pubDate>
            <content:encoded><![CDATA[<p>When working with multi-process applications, there comes a time where you’ll definitely need some sort of synchronization, and for that specific purpose we have the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.threading.mutex(v=vs.105).aspx"><strong>Mutex</strong></a> class.</p><p><abbr title="Microsoft Developer Network">MSDN</abbr> states the following for the Mutex class:</p><blockquote><p>When two or more threads need to access a shared resource at the same time, the system needs a synchronization mechanism to ensure that only one thread at a time uses the resource. Mutex is a synchronization primitive that grants exclusive access to the shared resource to only one thread. If a thread acquires a mutex, the second thread that wants to acquire that mutex is suspended until the first thread releases the mutex.</p></blockquote><p>Bottom line is that the mutex is a system wide <code>lock</code>, not just contained to the current process!</p><p>When it comes to usage, there is a major difference between them: the <code>lock</code> keyword is used to contain a thread-safe block of code, and when code is executed outside of that block, the locked object is released; the mutex on the other hand, doesn’t use the same approach, and as such has to manually be released.</p><p>One situation that you can get into is when a thread terminates while owning a mutex, the mutex is said to be abandoned, and this is a really bad thing, normally indicating a serious programming error.</p><p>Unfortunately, due to the volatile nature of the Windows Phone background agents, abandoned mutexes will eventually happen without any thing a developer can actually do, but to catch and treat the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.threading.abandonedmutexexception(v=vs.105).aspx"><strong>AbandonedMutexException</strong></a> that will get raised on the other awaiting thread (if one exists)!</p><p>The following code sample simulates how to raise and handle the <code>AbandonedMutexException</code>:</p><pre><code class="language-csharp">public static void MutextTest()
{
    var mutex = new Mutex(false, &quot;MyMutex&quot;);

    new Thread(() =&gt;
    {
        mutex.WaitOne();

        Thread.Sleep(1000);
    }).Start();

    Thread.Sleep(2000);

    try
    {
        mutex.WaitOne();
    }
    catch (AbandonedMutexException e)
    {
        Debug.WriteLine(e);
    }
    catch (Exception e)
    {
        Debug.WriteLine(e);
    }
}
</code></pre><p>When running the above in a Console application, this is the output we get from it:</p><blockquote><p>System.Threading.AbandonedMutexException: The wait completed due to an abandoned mutex.</p></blockquote><p>For the same code in a Windows Phone 8 app, this will be the output:</p><blockquote><p>System.Exception: The wait completed due to an abandoned mutex.</p></blockquote><p>The two platforms show an inconsistent result for the same behavior, as an <code>AbandonedMutexException</code> get thrown for the full .NET Framework, and a generic <code>Exception</code> for the <abbr title="Windows Phone 8">WP8</abbr> one.</p><p>Seems that the only thing in common is actually the message!…</p><p>One interesting fact is that the <code>Mutex</code> documentation for <abbr title="Windows Phone 8">WP8</abbr> does <strong>not</strong> mention the <code>AbandonedMutexException</code> class, though it does exist in the <abbr title="Windows Phone 8">WP8</abbr> class library, but doesn’t seem to be in use anywhere on the platform. This may be the result of having similar behavior as the <abbr title="Windows Phone 7">WP7</abbr> platform, where we would actually get the same behaviour due to the lack of the more specific <code>AbandonedMutexException</code> class.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit Updated to v3.0.0]]></title>
            <link>https://www.pedrolamas.com/2013/06/06/cimbalino-windows-phone-toolkit-updated-to-v3-0-0/</link>
            <guid>https://www.pedrolamas.com/2013/06/06/cimbalino-windows-phone-toolkit-updated-to-v3-0-0/</guid>
            <pubDate>Thu, 06 Jun 2013 17:17:15 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/58e959564fc7425d90e4f09137e0baa2/Cimbalino-Windows-Phone-Toolkit-300x270.png" alt="Cimbalino Windows Phone Toolkit Updated to v3.0.0" class="webfeedsFeaturedVisual" /></p><p>I’m proud to present the latest version of <a href="http://cimbalino.org"><strong>Cimbalino Windows Phone Toolkit</strong></a>!</p><p>This new version comes with a major breaking change: Visual Studio 2012 is now required, as the toolkit has taken the “async/await” path! :D</p><p>If you still use Visual Studio 2010 for your Windows Phone development, you can still use the previous version of the toolkit (but then again, seems like a really nice time to upgrade ;) )</p><p>And without further ado, here’s the change-log:</p><ul><li><strong>async/await</strong> support added for <abbr title="Windows Phone 7">WP7</abbr></li><li>New <strong>Cimbalino.Phone.Toolkit.Background</strong> component, fully compatible with Background Agents.</li><li>New <strong>ShellTileService</strong></li><li>New <strong>VoiceCommandService</strong></li><li>New <strong>LauncherService</strong></li><li>New <strong>NetworkInformationService</strong></li><li><strong>AsyncStorageService</strong> is now compatible with <abbr title="Windows Phone 7">WP7</abbr></li><li><code>BingMapsService</code> has been removed and the functionality moved to <code>MapsService</code></li><li>Several improvements and bug fixes!</li></ul>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Review of my WPUG talk]]></title>
            <link>https://www.pedrolamas.com/2013/05/24/review-of-my-wpug-talk/</link>
            <guid>https://www.pedrolamas.com/2013/05/24/review-of-my-wpug-talk/</guid>
            <pubDate>Fri, 24 May 2013 12:27:20 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/e14504b1d48edf92f14e71f269ee316f/WPUG.png" alt="Review of my WPUG talk" class="webfeedsFeaturedVisual" /></p><p>Last Monday I had the pleasure of participating in a <a href="http://wpug.net/">WPUG</a> event where I talked about the <a href="http://nokia.ly/musicapi">Nokia Music <abbr title="Application Programming Interface">API</abbr></a> and the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>.</p><p>I had quite a technical challenge, as I couldn’t access the internet from inside the emulator, no matter what I did!</p><p>After a couple of minutes in silent panic, I tried to bypass the connectivity problems the best I could, doing anything from showing a YouTube video of Nokia Music features to running the demos on my personal phone and showing it off in the air to the audience!</p><p>Other than that, the event went really good, and hopefully I’ll start seeing more and more people using the Nokia Music <abbr title="Application Programming Interface">API</abbr> and Cimbalino Windows Phone Toolkit in their apps! ;)</p><p>From the feedback I got, I can see people requesting more information about <abbr title="Model View ViewModel">MVVM</abbr>, so I’m going to point to two articles I wrote about two years ago for <a href="http://channel9.msdn.com/coding4fun">Coding4Fun</a> (now part of Microsoft Channel9):</p><ul><li><a href="http://channel9.msdn.com/coding4fun/articles/Currency-Converter-for-Windows-Phone-7">Currency Converter for Windows Phone 7</a></li><li><a href="http://channel9.msdn.com/coding4fun/articles/Currency-Converter-v2--Now-on-Caffeine">Currency Converter v2 - Now on Caffeine</a></li></ul><p>My big “thank you” to <a href="https://twitter.com/mrlacey">Matt Lacey</a> and <a href="https://twitter.com/TheRealRiaz">Riaz Ahmed</a> for the opportunity! :)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit: MultiBindingBehavior]]></title>
            <link>https://www.pedrolamas.com/2013/05/17/cimbalino-windows-phone-toolkit-multibindingbehavior/</link>
            <guid>https://www.pedrolamas.com/2013/05/17/cimbalino-windows-phone-toolkit-multibindingbehavior/</guid>
            <pubDate>Fri, 17 May 2013 15:29:59 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/58e959564fc7425d90e4f09137e0baa2/Cimbalino-Windows-Phone-Toolkit-300x270.png" alt="Cimbalino Windows Phone Toolkit: MultiBindingBehavior" class="webfeedsFeaturedVisual" /></p><p>One of the features I most enjoy in WPF is the <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.multibinding.aspx">MultiBinding</a> class, which allows you to take several source properties, pass their values to an <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter.aspx">IMultiValueConverter</a> implementation, and bind the result to a single target property!</p><p>By now you’re probably thinking “why do I need that?”, but in certain specific scenarios, having the possibility to take several values and produce a single result directly in the <abbr title="User Interface">UI</abbr> can be quite useful!</p><p>Take this sample from <abbr title="Microsoft Developer Network">MSDN</abbr>:</p><pre><code class="language-xml">&lt;TextBlock DataContext=&quot;{StaticResource NameListData}&quot;&gt;
  &lt;TextBlock.Text&gt;
    &lt;MultiBinding Converter=&quot;{StaticResource myNameConverter}&quot;
                  ConverterParameter=&quot;FormatLastFirst&quot;&gt;
      &lt;Binding Path=&quot;FirstName&quot;/&gt;
      &lt;Binding Path=&quot;LastName&quot;/&gt;
    &lt;/MultiBinding&gt;
  &lt;/TextBlock.Text&gt;
&lt;/TextBlock&gt;
</code></pre><p>We can easily infer that the objective here is to set the <code>TextBlock.Text</code> property to the result of “LastName, FirstName”, given the two properties from the specified <code>TextBlock.DataContext</code> and a custom <code>IMultiValueConverter</code> instance called myNameConverter.</p><p>While useful, the <code>MultiBinding</code> is not available for Windows Phone developers - queue the whining…</p><p>I’ve seen a few alternative implementations around the internet, but none seems easy (and light!) enough to me, so I just decided to make my own!</p><p>On the latest release of <a href="http://cimbalino.org/">Cimbalino Windows Phone Toolkit</a> I added the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit%20%28WP71%29/Behaviors/MultiBindingBehavior.cs">MultiBindingBehavior</a>, a quick and easy approach to solve the missing <code>MultiBinding</code> support in Windows Phone!</p><p>Here’s an example using the same scenario from above:</p><pre><code class="language-xml">&lt;TextBlock DataContext=&quot;{StaticResource NameListData}&quot;&gt;
    &lt;i:Interaction.Behaviors&gt;
        &lt;cimbalinoBehaviors:MultiBindingBehavior Converter=&quot;{StaticResource myNameConverter}&quot; ConverterParameter=&quot;FormatLastFirst&quot; PropertyName=&quot;Text&quot;&gt;
            &lt;cimbalinoBehaviors:MultiBindingItem Value=&quot;{Binding FirstName}&quot; /&gt;
            &lt;cimbalinoBehaviors:MultiBindingItem Value=&quot;{Binding LastName}&quot; /&gt;
        &lt;/cimbalinoBehaviors:MultiBindingBehavior&gt;
    &lt;/i:Interaction.Behaviors&gt;
&lt;/TextBlock&gt;
</code></pre><p>The major difference here is the usage of <code>MultiBindingBehavior.PropertyName</code>, as we can’t bind the target property directly, it will be up to the behavior to get/set the value. All the rest of the code is really quite self explanatory!</p><p>Here’s another sample using two TextBox controls to input the FirstName and LastName values:</p><pre><code class="language-xml">&lt;TextBox x:Name=&quot;FirstNameTextBox&quot; /&gt;
&lt;TextBox x:Name=&quot;LastNameTextBox&quot; /&gt;
&lt;TextBlock Style=&quot;{StaticResource PhoneTextLargeStyle}&quot;&gt;
    &lt;i:Interaction.Behaviors&gt;
        &lt;cimbalinoBehaviors:MultiBindingBehavior Converter=&quot;{StaticResource myNameConverter}&quot; ConverterParameter=&quot;FormatLastFirst&quot; PropertyName=&quot;Text&quot;&gt;
            &lt;cimbalinoBehaviors:MultiBindingItem Value=&quot;{Binding Text, ElementName=FirstNameTextBox}&quot; /&gt;
            &lt;cimbalinoBehaviors:MultiBindingItem Value=&quot;{Binding Text, ElementName=LastNameTextBox}&quot; /&gt;
        &lt;/cimbalinoBehaviors:MultiBindingBehavior&gt;
    &lt;/i:Interaction.Behaviors&gt;
&lt;/TextBlock&gt;
</code></pre><p>You can set the <code>MultiBindingBehavior.Converter</code> property to any <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.data.ivalueconverter%28v=vs.105%29.aspx">IValueConverter</a> instance (knowing that the <code>value</code> parameter is always an <code>object[]</code> instance) but I’ve also added an abstract <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit%20%28WP71%29/Converters/MultiValueConverterBase.cs">MultiValueConverterBase</a> that you can inherit and implement quite easily!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WPUG London meeting 20 May: Nokia Music & demo showcase]]></title>
            <link>https://www.pedrolamas.com/2013/05/16/wpug-london-meeting-20-may-nokia-music-demo-showcase/</link>
            <guid>https://www.pedrolamas.com/2013/05/16/wpug-london-meeting-20-may-nokia-music-demo-showcase/</guid>
            <pubDate>Thu, 16 May 2013 13:56:46 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/e14504b1d48edf92f14e71f269ee316f/WPUG.png" alt="WPUG London meeting 20 May: Nokia Music & demo showcase" class="webfeedsFeaturedVisual" /></p><p>I’m happy to confirm that my first presentation in the <abbr title="United Kingdom">UK</abbr> will be for the <a href="http://wpug.net/">WPUG</a> May 20 event.</p><p>I’ll be talking about the <a href="http://nokia.ly/musicapi">Nokia Music <abbr title="Application Programming Interface">API</abbr></a> and the Nokia Music app, but you can also count on some good info on the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>!</p><p>The event venue is <a href="http://her.is/L4ycb">Nokia’s office in Paddington, London</a>, and <strong><a href="http://wpug31.eventbrite.com/">registration</a> is free and required</strong>!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit updated to v2.3.0]]></title>
            <link>https://www.pedrolamas.com/2013/05/08/cimbalino-windows-phone-toolkit-updated-to-v2-3-0/</link>
            <guid>https://www.pedrolamas.com/2013/05/08/cimbalino-windows-phone-toolkit-updated-to-v2-3-0/</guid>
            <pubDate>Wed, 08 May 2013 19:41:19 GMT</pubDate>
            <content:encoded><![CDATA[<p><img src="https://www.pedrolamas.com/static/58e959564fc7425d90e4f09137e0baa2/Cimbalino-Windows-Phone-Toolkit-300x270.png" alt="Cimbalino Windows Phone Toolkit updated to v2.3.0" class="webfeedsFeaturedVisual" /></p><p>I just released a new <a href="http://cimbalino.org"><strong>Cimbalino Windows Phone Toolkit</strong></a> version!</p><p>Here’s a short list of all the goodies you’ll find in the <strong>2.3.0</strong> version:</p><ul><li>Breaking change: Location component now uses the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff431800%28v=vs.105%29.aspx">new Windows Phone 8 Location <abbr title="Application Programming Interface">API</abbr></a> (Geolocator) on <abbr title="Windows Phone 8">WP8</abbr> (<abbr title="Windows Phone 7">WP7</abbr> version will mimic behavior with GeoCoordinateWatcher)</li><li>Breaking change: In <abbr title="Windows Phone 8">WP8</abbr>, the <code>UserExtendedPropertiesService.AnonymousUserID</code> now returns the “ANID2” value (<abbr title="Windows Phone 7">WP7</abbr> version will still return “ANID”)</li><li>New <strong>MultiBindingBehavior</strong></li><li>New <strong>OptimizedObservableCollection</strong> class</li><li>Several improvements and bug fixes!</li></ul><p>I didn’t actually release a change log for the previous <strong>2.2.0</strong> version, so here it is now:</p><ul><li>New <strong>MutexLock</strong> and <strong>NamescopeBinding</strong> helper classes</li><li>New <strong>BooleanToBrushConverter</strong> and <strong>BooleanToIntConverter</strong></li><li>New <strong>UriExtensions</strong> class</li><li>The <code>ApplicationBarBehavior</code> and <code>MultiApplicationBarBehavior</code> can now be attached to the <code>PhoneApplicationPage</code></li><li>The <code>SystemTrayService</code> implementation now allows for a global system tray across all pages</li><li>Removed the <code>cimbalino = http://cimbalino.org</code> <abbr title="Extensible Markup Language">XML</abbr> namespace prefix (incompatible with <abbr title="Windows Phone 8">WP8</abbr>)</li><li>Several improvements and bug fixes</li></ul><p>A big “thank you” is due to <a href="http://metronuggets.com/">Scott Lovegrove</a> for his continuous code contributions and articles about the toolkit!</p><p>Now to write some posts about the new features… ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding XAML Namescopes]]></title>
            <link>https://www.pedrolamas.com/2013/05/02/understanding-xaml-namescopes/</link>
            <guid>https://www.pedrolamas.com/2013/05/02/understanding-xaml-namescopes/</guid>
            <pubDate>Thu, 02 May 2013 13:31:31 GMT</pubDate>
            <content:encoded><![CDATA[<p>I’ve been getting some inquires about the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/tree/master/samples/BindableApplicationBar">BindableApplicationBar sample</a> from the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>, specifically about what is the <code>NamescopeBinding</code> resource appearing on the top of the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/samples/BindableApplicationBar/BindableApplicationBar/View/MainPage.xaml">MainPage.xaml</a> file.</p><p>Here is the specific bit:</p><pre><code class="language-xml">&lt;phone:PhoneApplicationPage.Resources&gt;
    &lt;cimbalinoHelpers:NamescopeBinding x:Key=&quot;ItemsMultiselectList&quot; Source=&quot;{Binding ElementName=ItemsMultiselectList}&quot; /&gt;
&lt;/phone:PhoneApplicationPage.Resources&gt;
</code></pre><p>This special class has a single property called <code>Source</code> that can be set to any object; in this sample, it’s pointing to a named control inside the pages LayoutRoot (hence the single <code>Binding.ElementName</code> property set)</p><p>If you look a bit down the code, you’ll find the <code>ApplicationBarIconButton.CommandParameter</code> where this resource is getting referenced:</p><pre><code class="language-xml">&lt;cimbalinoBehaviors:ApplicationBarIconButton
    Command=&quot;{Binding DeleteItemsCommand, Mode=OneTime}&quot;
    CommandParameter=&quot;{Binding Source.SelectedItems, Source={StaticResource ItemsMultiselectList}}&quot;
    IconUri=&quot;/Images/appbar.delete.rest.png&quot;
    Text=&quot;delete&quot; /&gt;
</code></pre><p>If we just put the two parts together, we can see that the whole objective is to bind the <code>ApplicationBarIconButton.CommandParameter</code> property to <code>ItemsMultiselectList.SelectedItems</code> property.</p><p>Obviously you’d expect to just do it directly, like this:</p><pre><code class="language-xml">&lt;cimbalinoBehaviors:ApplicationBarIconButton
    Command=&quot;{Binding DeleteItemsCommand, Mode=OneTime}&quot;
    CommandParameter=&quot;{Binding SelectedItems, ElementName=ItemsMultiselectList}&quot;
    IconUri=&quot;/Images/appbar.delete.rest.png&quot;
    Text=&quot;delete&quot; /&gt;
</code></pre><p>In reality, this approach doesn’t work from the <code>PhoneApplicationPage</code> point of view, due to the different <strong><abbr title="Extensible Application Markup Language">XAML</abbr> Namescope</strong>.</p><h2><abbr title="Extensible Application Markup Language">XAML</abbr> Namescope??</h2><p>Here is the <abbr title="Extensible Application Markup Language">XAML</abbr> Namescope definition found in <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc189026%28v=vs.105%29.aspx">this</a> <abbr title="Microsoft Developer Network">MSDN</abbr> article:</p><blockquote><p>…a <abbr title="Extensible Application Markup Language">XAML</abbr> namescope stores relationships between the <abbr title="Extensible Application Markup Language">XAML</abbr>-defined names of objects and their instance equivalents. This is similar to the wider meaning of the term “namescope” in other programming languages and technologies.</p></blockquote><p>So think of the <abbr title="Extensible Application Markup Language">XAML</abbr> Namescope as a hash-table with each control name and it’s instance (something like <code>IDictionary&lt;string, FrameworkElement&gt;</code>).</p><p>The problem is that the page’s LayoutRoot control gets a different <abbr title="Extensible Application Markup Language">XAML</abbr> Namescope from the page itself, so searching for a child control from inside the page just won’t work!</p><p>The following image illustrates the Namescope boundaries for a default new page:</p><p><a href="/7bca3c6e932bfd34637d720896820898/XAML-Namescope-boundaries.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:480px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:74.44444444444443%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAB/0lEQVQoz22Ri26kMAxF+Y9JYsd5PyBAJsAAVdv//6kVna7Uzm50dGVFOoodd0MZ78tW12NajnnZyUXUVggBgAIAAAGlABCcX/w+nQ45zZvum+6bKZstqx0WMzRbNjvuKo7kszQBJAGpV9mmYdzeY91Vrq596vLQ4/5MO53+/u7qm06T6RuZ8I8ch3H/jKWO0zzWpUz1vtxrq21d8jiTH8j30nhURnD2Khufpv2zzG2p01z6MuSl5sc67+uUc0JJf0d9HfiSlYu5nbmdpp+Vz2gjV1aQ4ai4vGBC/BcuROcQizO91YkoGz1YNRidCbKWWWFCngiSFJ7znwTOLeddAZiH4TzP/XG0tg3j3JcafHQ+Wus1gkKhQJB4JXPeBcYE4nG+fXy8r9sjzysoKwBut9uNsatDfnX4C7gyPmVjTS7J5+Bz1N4Yb8gockY5LRUggdSIBFxwxq/zzMhYFxkjpbZt248jzYsrLdQjTFuYN9+PKaWcUx/dNISx93PxKVpryGhKQlyyJJqmsc8JEFESICEpSSQQn4WSUitSJLWWRkurpVbykgNjymiXgsmBnNcx6uhtjspblxNZC2Q5SMYZ+2qYcX77ysBYlxnvQ0zOk8DvR0FqqRSglqRQqusG/v3tnvOuhnCU0oKvzrbgoxCOMc+Y58yzm/+ur8X+JH5t+w/A2YQeSLI8+wAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="XAML Namescope boundaries thumb" title="XAML Namescope boundaries thumb" src="/static/367f0f44a55ee74d5dac85d41164ef5d/e85cb/XAML-Namescope-boundaries-thumb.png" srcSet="/static/367f0f44a55ee74d5dac85d41164ef5d/e9ff0/XAML-Namescope-boundaries-thumb.png 180w,/static/367f0f44a55ee74d5dac85d41164ef5d/f21e7/XAML-Namescope-boundaries-thumb.png 360w,/static/367f0f44a55ee74d5dac85d41164ef5d/e85cb/XAML-Namescope-boundaries-thumb.png 480w" sizes="(max-width: 480px) 100vw, 480px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>This is where the <code>NamescopeBinding</code> helper class makes its entry: just register an instance of this class as a page resource and bind the <code>NamescopeBinding.Source</code> property to the control you require outside the LayoutRoot <abbr title="Extensible Application Markup Language">XAML</abbr> Namescope as shown in the sample code, and that’s it!</p><p>In the BindableApplicationBar sample, if you actually attach the <code>MultiApplicationBarBehavior</code> to the LayoutRoot instead of the page, it will work perfectly without the need for the <code>NamescopeBinding</code> helper class.</p><p>But my advice is to always bind the <code>ApplicationBarBehavior</code> and <code>MultiApplicationBarBehavior</code> to the page as it will provide better integration and more fluid animation, and use the <code>NamescopeBinding</code> helper class if needed.</p><p>I’ve created a small sample app that demonstrates the <abbr title="Extensible Application Markup Language">XAML</abbr> Namescope behavior and how it affects your applications, which you can download from <a href="/383f377367f336258f03349c78f55112/XamlNamescopeDemo.zip">here</a>.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Assert.ThrowsException the async way]]></title>
            <link>https://www.pedrolamas.com/2013/04/30/assert-throwsexception-the-async-way/</link>
            <guid>https://www.pedrolamas.com/2013/04/30/assert-throwsexception-the-async-way/</guid>
            <pubDate>Tue, 30 Apr 2013 17:19:37 GMT</pubDate>
            <content:encoded><![CDATA[<p>The new Windows Phone Test Framework on Visual Studio 2012 Update 2 is a major step in the right direction for testing <abbr title="Windows Phone">WP</abbr> apps.</p><p>I particularly like the fact that all tests run on the emulator where they can get the full runtime environment of a real Windows Phone device.</p><p>Yet, the test framework still has some pitfalls where we realize it is just not enough!</p><p>A few weeks ago I wrote an <a href="/2013/03/25/windows-phone-8-unit-testing-in-the-ui-thread-with-vs-2012-2-ctp4/">article</a> about one of these pitfalls, on how to run code in the <abbr title="User Interface">UI</abbr> Thread.</p><p>Now I’ve stumbled in yet another pitfall, this time on how to run the <code>Assert.ThrowsException</code> with <code>async</code> code!</p><p>Microsoft solved this issue on the Windows 8 version of the Test Framework, by adding some <code>Task&lt;Exception&gt; Assert.ThrowsException(Func&lt;Task&gt;)</code> methods, but there is no equivalent in Windows Phone.</p><p>This is my personal implementation of these methods for the Windows Phone Test Framework:</p><pre><code class="language-csharp">public static class AssertExtensions
{
    public static Task&lt;T&gt; ThrowsExceptionAsync&lt;T&gt;(Func&lt;Task&gt; action)
        where T : Exception
    {
        return ThrowsExceptionAsync&lt;T&gt;(action, string.Empty, null);
    }

    public static Task&lt;T&gt; ThrowsExceptionAsync&lt;T&gt;(Func&lt;Task&gt; action, string message)
        where T : Exception
    {
        return ThrowsExceptionAsync&lt;T&gt;(action, message, null);
    }

    public async static Task&lt;T&gt; ThrowsExceptionAsync&lt;T&gt;(Func&lt;Task&gt; action, string message, object[] parameters)
        where T : Exception
    {
        try
        {
            await action();
        }
        catch (Exception ex)
        {
            if (ex.GetType() == typeof(T))
            {
                return ex as T;
            }

            var objArray = new object[] {
                &quot;AssertExtensions.ThrowsExceptionAsync&quot;,
                string.Format(CultureInfo.CurrentCulture, FrameworkMessages.WrongExceptionThrown, message, typeof(T).Name, ex.GetType().Name, ex.Message, ex.StackTrace)
            };

            throw new AssertFailedException(string.Format(CultureInfo.CurrentCulture, FrameworkMessages.AssertionFailed, objArray));
        }

        var objArray2 = new object[] {
            &quot;AssertExtensions.ThrowsExceptionAsync&quot;,
            string.Format(CultureInfo.CurrentCulture, FrameworkMessages.NoExceptionThrown, message, typeof(T).Name)
        };

        throw new AssertFailedException(string.Format(CultureInfo.CurrentCulture, FrameworkMessages.AssertionFailed, objArray2));
    }
}
</code></pre><p>Just copy the above code to your test project and then use it like in this sample:</p><pre><code class="language-csharp">[TestMethod]
public async Task MyTestMethod()
{
    await AssertExtensions.ThrowsExceptionAsync&lt;ArgumentException&gt;(async () =&gt;
    {
        await Windows.Storage.StorageFolder.GetFolderFromPathAsync(&quot;&quot;);
    });
}
</code></pre>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[App Package Cleanup]]></title>
            <link>https://www.pedrolamas.com/2013/04/26/app-package-cleanup/</link>
            <guid>https://www.pedrolamas.com/2013/04/26/app-package-cleanup/</guid>
            <pubDate>Fri, 26 Apr 2013 22:10:58 GMT</pubDate>
            <content:encoded><![CDATA[<p>The <a href="http://nuget.org">NuGet</a> team released the 2.5 version yesterday, and along with a bunch of really cool <a href="http://docs.nuget.org/docs/release-notes/nuget-2.5">new features</a>, there was one I was particularly interested: the ability to import MSBuild targets and props files!</p><p>This means we can now have NuGet packages without any type of assembly, targeting only the project build process.</p><p>And if you’ve read <a href="/2013/02/15/reduce-the-size-of-your-xapappx-package-time-to-take-out-the-trash/">this article</a> about the issue with the current build process for Windows 8 and Windows Phone 8 apps, where the Xml Documentation gets bundled in the output packages (APPX and XAP), I have some great news: no more need to change the project file manually, as I just published a <a href="https://nuget.org/packages/AppPackageCleanup">NuGet package</a> that does those changes for you!!</p><p>All you have to do is run the following command from the Package Manager console window:</p><p><a href="https://nuget.org/packages/AppPackageCleanup"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:534px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:13.333333333333334%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAoElEQVQI1z2KwQ6CMBiDeQWu3CWRKGFENogEZGz7+ff+72C4ejar2VAPTfu1zYgobNv2F7MP3vuU40Z0eOyYOfz+MUfF7JwLxpg3MyMryxNa0UJ2CkI0qC415K2D6iTmx4y6vmIcRkz3CUoq9Eph0QsaIdD3Q+qrc4U8z1EUBTJjzB5lrU2utd7XdU1MRKmLbs2xO+cSp8+X41dr/SSi1wdFZmahZPk+vgAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="InstallPackage AppPackageCleanup" title="InstallPackage AppPackageCleanup" src="/static/848a5199d8aa5242e9ecab88911baa7e/a07a7/AppPackageCleanup.png" srcSet="/static/848a5199d8aa5242e9ecab88911baa7e/e9ff0/AppPackageCleanup.png 180w,/static/848a5199d8aa5242e9ecab88911baa7e/f21e7/AppPackageCleanup.png 360w,/static/848a5199d8aa5242e9ecab88911baa7e/a07a7/AppPackageCleanup.png 534w" sizes="(max-width: 534px) 100vw, 534px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>If you have NuGet Package Manager extension installed on Visual Studio, just search for <code>AppPackageCleanup</code> to install the Package.</p><p><strong>Note:</strong> this package requires NuGet 2.5 as it won’t show up in the search results with previous versions of NuGet!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Phone 8 Unit Testing in the UI thread with VS 2012.2 CTP4]]></title>
            <link>https://www.pedrolamas.com/2013/03/25/windows-phone-8-unit-testing-in-the-ui-thread-with-vs-2012-2-ctp4/</link>
            <guid>https://www.pedrolamas.com/2013/03/25/windows-phone-8-unit-testing-in-the-ui-thread-with-vs-2012-2-ctp4/</guid>
            <pubDate>Mon, 25 Mar 2013 12:37:34 GMT</pubDate>
            <content:encoded><![CDATA[<p>If you’ve been following <a href="http://blogs.msdn.com/b/visualstudioalm/archive/2013/01/31/windows-phone-unit-tests-in-visual-studio-2012-update-2.aspx">the news</a> on the upcoming <strong>Visual Studio 2012 Update 2</strong> (currently in <a href="http://go.microsoft.com/fwlink/?LinkId=273878">CTP4</a>), you know that we now have a fully working Unit Tests framework for Windows Phone projects!</p><p>Well, this seemed like the perfect opportunity to finally create some unit tests for the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a> and test this new test framework, all at once!</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:200px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:96.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAFGklEQVQ4y02UaUzUVxTFL8gHqemnfrC1mlZTbVNjW0yatraNrU2jUdoChVkYQGq0QAUNLmmqFrc0GhFbENKylEVkF1QWQQHBGQnKIvsyOP9ZGAadgRl2nOX/3mlmoE1vcnLyvvzycu7JJSZIiWnDiWkCvJggIWaI2yD2rN3Cx89eZ6ZzNdxW+pxNZA0ya5GRmc7c46ZTKWLfxs3MePxVppUT04R4c91e8nAECRHT7yemjyZuTvNhT/3fYbrwY2wil7GZ5nk4BMBhBFwmwDUG95vP1M8yS6aDab7fywTZ23aAYIonjP5I0MuIABA3X125eJx8uCmhlltLAJeGwaWDuDDi6mq7w026VrZg6+Pztn4XHDrAMeDk1kIw47Fs7gY+/20leB3BdoJI7NtEC5fJmxmP1/HJfCsWe2AZbWa6oTqubLiOezV5vOZWDlofFPO2h6WA2M1tJhVjc51glowJ0RBfANho4QGRc3g3EdNG+DKtIpA9u6TBvBIL5ruuqvI0VN/8E+2qa1zoK0PPowKo6rMw3FXMjepKVJRcxUBHiRMuFRyGhC6XoPga5kgfGNcSYU5FoiGuCjOFmNCVOVsa0tGuzOS9rVlgtkpgpgqYqwafqgQW7sAwkM/rbv3Bm2rT8Lj5b4fLnANrT0QBkE7AXW8SNRJ/bjox4DTn4mZJIvsr9Ry3anOB+RJgugiYKlzStNsLgLkSiJMF6HiQzIvyzvMZQwbsuqPd5nb/7S71N0Qu9Z73Mf7rrH08HR3NF1mXMhGYzoSxPxXV5cm4V5WGxpqraKlPRm9rKh7fTwKsGZjVp2JSk8YwlQHbQNzU+fiNHxlVn7kzVCSwsV+cMCcBtisc5ssctiR0NF1Cfs5llBYkofhaIiqKLiEz/XcoaxMB6xWw51c4LBc51++HfTjQ1Vm98yQgEjFNoB8zxE4y02mIYwmMmRIASwKGH8ZDdTsGbXUxUN6KwtDDI8jJuIDxvrPA+M/go3EQBTmDXoKJziBrWMAbEnIPE6RyZogys9F4DtNR/kI4ymH4ARgNAXQScK0UGJPCPiJHS2UkoFMAo1IsDodyJsg4dDI2+SRwJuPCh4fdnSYY9hETZDdg2IfZoShnRW40Gm9E8dnBSECvAAxyTHaH44U6DAtDYbD1RqC7IYoXZcVi9NFeEc9C0VS0o4mI/GCLcG85eJVLIz8NQ6jR1CaH8mYkq8iLQWn2QdwpPsi7G6JRlh2Fxoo41BbH8LKcWBRkHkJmSixTKyMw0xtkLkrZVrxmte+Gj/1ecWcYQmL/e16iRtoFvUxcHJaJQ81h/HZ+DE9PPozS7J94Q9kBNJbH8Ny0A7hffoCPKBXc0qUQuVbOBut3q4noCyLyXc5Q5s7xZa6VbRIFqQo6GWCQ2ecG5NzcGcq0LWEewFSvglueyJhdLedMkDphUeBJ9c5e/x1rond/+dpbkcHrKSLoTVo+O1KCzgMOFAVpMhOkgE7KYJABozIOowzQu13uWRLXynA78/O7KWe2niWidUE7X6d9Ieu9AO0SUNRI3O6zDN/KBGkkE6RNzhGp0fVUKtrVEoddLRHn+oOn1Pf3tBUmf5JyMHxjIBG9BMBrle8Kr6STH9Cp2HeXgLDGENd6frjC7VzrAfstDAavWxwKOaVV+u8ytwecSTi0eWtd3vbtROR17sgWb09NluerT1fTvz30aAn0n1a4oZaOAFocCqGx1m8J05HUW7eLnCMSzw0df/zdEmjbavr//ANbFwSxL6pVfgAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Works on my machine" title="Works on my machine" src="/static/629e3e3cd1943d6e5338810e3f71e8ba/772e8/Works-on-my-machine.png" srcSet="/static/629e3e3cd1943d6e5338810e3f71e8ba/e9ff0/Works-on-my-machine.png 180w,/static/629e3e3cd1943d6e5338810e3f71e8ba/772e8/Works-on-my-machine.png 200w" sizes="(max-width: 200px) 100vw, 200px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>Given that this post will require installing the VS2012.2 <abbr title="Community Technology Preview">CTP</abbr> 4, a non-final preview version software that has a “go-live” license, I think it’s only proper to apply the <abbr title="Works On My Machine">WOMM</abbr> certification to it.</p><p>So bottom line, install it at your own risk!</p><p>So I started by installing the update, launch Visual Studio 2012, and create a new Windows Phone Unit Test App.</p><p>Then, I used NuGet to add a reference to the <a href="http://nuget.org/packages/Cimbalino.Phone.Toolkit">Cimbalino Windows Phone Toolkit</a> and then added the following test class:</p><pre><code class="language-csharp">namespace Cimbalino.Phone.Toolkit.Tests.Converters
{
    [TestClass]
    public class ColorToBrushConverterTests
    {
        [TestMethod]
        public void ConvertWithColorReturnsBrush()
        {
            var converter = new ColorToBrushConverter();

            var expected = Colors.Blue;

            var actual = converter.Convert(Colors.Blue, typeof(string), null, CultureInfo.CurrentCulture);

            Assert.IsInstanceOfType(actual, typeof(SolidColorBrush));
            Assert.AreEqual(((SolidColorBrush)actual).Color, expected);
        }
    }
}
</code></pre><p>This simple class will test the <code>ColorToBrushConverter.Convert</code> method as to check for the proper creation of a <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/system.windows.media.solidcolorbrush%28v=vs.105%29.aspx">SolicColorBrush</a> out of a specific <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/system.windows.media.color%28v=vs.105%29.aspx">Color</a>.</p><p>When I ran the test, this is what happened:</p><p><a href="/04797d6652a825f451107b85527e3d49/Windows-Phone-Unit-Test-results.png"><figure class="gatsby-resp-image-figure" style="margin-left:auto;margin-right:auto;max-width:691px">
    <span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:691px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:63.33333333333333%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAB8ElEQVQoz43QTW7TQBQHcF+h3KCeD3s+PPHY82XHmcTjVDRJE0JdxIYiFg0SiEUkJJYcgBMg1FRCsOQIHA5MpC4jpJ+eNIv33v9NRD7+RPvvT94+nO0OZ3f3g93hf5zvf0StyD3lgfEpoZ5mnnKfEp8kp00w7jiPuKylGnMuUzLC3GFuKREEYYKS0xKAo1dvPr388vv551+z/UPz/qt9943d3bPd4TS6O9gPh2hcTWbd5Sxc1ONJXmhZmoSKARslLD8hZXlUKDWbelNPdRNs09pxC4kACcM4wQidACGMOqUqV/HCMdVI64VqcuuzsooBjuMYAAgAiOPB+Xn8WOMYQIgiW5Z9/2Kzudo+26wWl86ayjlrtJSFUrooyqJUSmmtTV3VRltjrTZGa52mJOJidHv7uu/70M3n84sQurYNszaE0IXQzbvO+2lRFFIWWg+zykJJOTyTJI2EGIU21HVTj8eMcUZZlgnOBecZYzzLBCH0X3h4TPtoiM0Yn3jvJz7PpbFW5hIAdPwUCBGEKElShDAAEEJ0nIIQxjhBCEdxDJpmctPfXF/32+12vVmvVuur9XqxWCwXy+Vy9fRyUbtKKV2W+ng85xmEw4IIQiSEcNZpbZTWSmtjrHOVMc65qqoqxliaUkoZIZRQRik7Zvnb/Ad4pawU+UHVBQAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Windows Phone Unit Test results" title="Windows Phone Unit Test results" src="/static/04797d6652a825f451107b85527e3d49/e185b/Windows-Phone-Unit-Test-results.png" srcSet="/static/04797d6652a825f451107b85527e3d49/e9ff0/Windows-Phone-Unit-Test-results.png 180w,/static/04797d6652a825f451107b85527e3d49/f21e7/Windows-Phone-Unit-Test-results.png 360w,/static/04797d6652a825f451107b85527e3d49/e185b/Windows-Phone-Unit-Test-results.png 691w" sizes="(max-width: 691px) 100vw, 691px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span>
    <figcaption class="gatsby-resp-image-figcaption">Windows Phone Unit Test results</figcaption>
  </figure></a></p><p>As you can see here, we got an “Invalid cross-thread access” error message; this is the result of all tests running on a special “test app” inside the Emulator, but the really bad news is that they all run in a background thread.</p><p>Apparently, if this was a Windows Store app we could just change the <code>[TestMethod]</code> attribute with the proper <code>[UITestMethod]</code> one as to mark the requirement of running the test in the <abbr title="User Interface">UI</abbr> Thread, but unfortunately, the attribute is currently missing from the Windows Phone test framework!</p><p>So I decided to fix that and create my very own <code>UITestMethodAttribute</code>, and here it is:</p><pre><code class="language-csharp">[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class UITestMethodAttribute : TestMethodAttribute
{
    public override TestResult[] Execute(ITestMethod testMethod)
    {
        TestResult[] result = null;

        var ar = new AutoResetEvent(false);

        Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
        {
            try
            {
                result = base.Execute(testMethod);
            }
            finally
            {
                ar.Set();
            }
        });

        ar.WaitOne();

        return result;
    }
}
</code></pre><p>If you don’t like using the <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/system.threading.autoresetevent%28v=vs.105%29.aspx">AutoResetEvent</a>, then you can use this alternative version with the new <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.threading.tasks%28v=vs.105%29.aspx">Tasks</a>:</p><pre><code class="language-csharp">[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class UITestMethodAttribute : TestMethodAttribute
{
    public override TestResult[] Execute(ITestMethod testMethod)
    {
        var task = ExecuteOnUi(testMethod);

        task.Wait();

        return task.Result;
    }

    private Task&lt;TestResult[]&gt; ExecuteOnUi(ITestMethod testMethod)
    {
        var tsc = new TaskCompletionSource&lt;TestResult[]&gt;();

        Deployment.Current.Dispatcher.BeginInvoke(() =&gt;
        {
            tsc.SetResult(base.Execute(testMethod));
        });

        return tsc.Task;
    }
}
</code></pre><p>For a usage sample, please refer to the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/tree/master/src/Cimbalino.Phone.Toolkit.Tests%20%28WP8%29">Cimbalino.Phone.Toolkit.Tests</a> project!</p><p>Other approaches to solve this issue can be found in <a href="http://dotnetbyexample.blogspot.nl/2013/03/unit-testing-async-windows-phone-8-code.html">this post</a> by <a href="http://dotnetbyexample.blogspot.nl/">Joost van Schaik</a> or <a href="https://gist.github.com/JakeGinnivan/5219390">this gist</a> from <a href="http://jake.ginnivan.net/">Jake Ginnivan</a>, both relying on just running the necessary code in the <abbr title="User Interface">UI</abbr> instead of the full test method as with the above approach.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit: MultiApplicationBarBehavior]]></title>
            <link>https://www.pedrolamas.com/2013/03/11/cimbalino-windows-phone-toolkit-multiapplicationbarbehavior/</link>
            <guid>https://www.pedrolamas.com/2013/03/11/cimbalino-windows-phone-toolkit-multiapplicationbarbehavior/</guid>
            <pubDate>Mon, 11 Mar 2013 15:39:40 GMT</pubDate>
            <content:encoded><![CDATA[<p>My <a href="/2013/03/05/cimbalino-windows-phone-toolkit-applicationbarbehavior/">previous article</a> showed how to use the <strong>ApplicationBarBehavior</strong> from the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a> to build applications with <abbr title="Model View ViewModel">MVVM</abbr> pattern and still use the Application Bar control without the need for any code-behind.</p><p>More than just controlling the app bar from the ViewModel, the <code>ApplicationBarBehavior</code> adds some nice new properties that you can’t find in the native app bar control.</p><p>Such is the nature of the <code>IsVisible</code> property found in the buttons and menu items, allowing to change the app bar contents with some ease!</p><p>To demonstrate the <code>IsVisible</code> property, I’ll use the sample code from the previous article: this will generate an app bar with 3 buttons, the first two will appear when <code>IsSelectionDisabled = true</code> and the 3rd one will appear when <code>IsSelectionEnabled = true</code> (the opposite state).</p><p>This is the recorded animation of what the state changing causes to the application bar buttons visibility:</p><p><img src="/766e0fffc873b3bd2ac33a5a041e67d0/ApplicationBarBehavior.gif" alt="ApplicationBarBehavior"/></p><p>As you can see, it works perfectly! Well, almost perfectly…</p><p>If you look really closely, you’ll notice that the animation doesn’t seem quite that smooth!</p><p>By making time go a bit slower, this is what is actually happening:</p><p><img src="/72718fe90a1247384a89317bd1c3ed65/ApplicationBarBehavior-Slower.gif" alt="ApplicationBarBehavior (Slower)"/></p><p>As you can see above, the buttons <strong>move</strong> before the animation starts!</p><p>This behavior is due to the nature of the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.applicationbar.buttons%28v=vs.105%29.aspx">ApplicationBar.Buttons</a> and <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.applicationbar.menuitems%28v=vs.105%29.aspx">ApplicationBar.MenuItems</a> collections: their type is <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.collections.ilist%28v=vs.105%29.aspx">IList</a>, and as such, all we really have is the <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist.add.aspx">Add</a>, <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist.remove.aspx">Remove</a> and <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist.clear.aspx">Clear</a> methods to manipulate the collection items.</p><p>And that is exactly what the <code>ApplicationBarBehavior</code> does behind the scenes: add or remove items when the <code>IsVisible</code> property of each item changes, and that is why we actually see this animation glitch.</p><h2>Now presenting the MultiApplicationBarBehavior</h2><p>Fixing this issue will require changing the whole application bar associated with the page, instead of just adding or removing buttons one by one.</p><p>And that is exactly what the <strong>MultiApplicationBarBehavior</strong> does: it allows you to have multiples application bar controls representing different states of the app bar!</p><p>Here’s the same app bar from the first article, now using the “multi” version:</p><pre><code class="language-xml">&lt;!-- remaining code --&gt;

&lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;Transparent&quot;&gt;
    &lt;i:Interaction.Behaviors&gt;
        &lt;cimbalino:MultiApplicationBarBehavior SelectedIndex=&quot;{Binding ApplicationBarSelectedIndex}&quot;&gt;
            &lt;cimbalino:ApplicationBar&gt;
                &lt;cimbalino:ApplicationBarIconButton Command=&quot;{Binding AddItemCommand, Mode=OneTime}&quot; IconUri=&quot;/Images/appbar.add.rest.png&quot; Text=&quot;add&quot; /&gt;
                &lt;cimbalino:ApplicationBarIconButton Command=&quot;{Binding EnableSelectionCommand, Mode=OneTime}&quot; IconUri=&quot;/Images/appbar.manage.rest.png&quot; Text=&quot;select&quot; /&gt;
            &lt;/cimbalino:ApplicationBar&gt;
            &lt;cimbalino:ApplicationBar&gt;
                &lt;cimbalino:ApplicationBarIconButton Command=&quot;{Binding DeleteItemsCommand, Mode=OneTime}&quot; CommandParameter=&quot;{Binding SelectedItems, ElementName=ItemsMultiselectList}&quot; IconUri=&quot;/Images/appbar.delete.rest.png&quot; Text=&quot;delete&quot; /&gt;
            &lt;/cimbalino:ApplicationBar&gt;
        &lt;/cimbalino:MultiApplicationBarBehavior&gt;
    &lt;/i:Interaction.Behaviors&gt;

    &lt;!-- remaining code --&gt;

&lt;/Grid&gt;

&lt;!-- remaining code --&gt;
</code></pre><p>Major difference here is the presence of multiple <code>ApplicationBar</code> entries, but also the <code>MultiApplicationBarBehavior.SelectedIndex</code> property which will allow you to select what app bar you want to show.</p><p>Here’s the recording of the app bar transition now:</p><p><img src="/e5a62f67aca1d2728991308e3c546029/MultiApplicationBarBehavior.gif" alt="MultiApplicationBarBehavior"/></p><p>Much nicer, but just to make sure, here is the same animation but about 5 times slower:</p><p><img src="/426449ed4d032452a6f81ca76949a8af/MultiApplicationBarBehavior-Slower.gif" alt="MultiApplicationBarBehavior (Slower)"/></p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cimbalino Windows Phone Toolkit: ApplicationBarBehavior]]></title>
            <link>https://www.pedrolamas.com/2013/03/05/cimbalino-windows-phone-toolkit-applicationbarbehavior/</link>
            <guid>https://www.pedrolamas.com/2013/03/05/cimbalino-windows-phone-toolkit-applicationbarbehavior/</guid>
            <pubDate>Tue, 05 Mar 2013 10:05:31 GMT</pubDate>
            <content:encoded><![CDATA[<p><a href="http://cimbalino.org"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:150px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:100%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB4UlEQVQ4y7WUy0sbURTGz70ZSyjmodOZpFYq3SkotpTSpSJWXCm4ceP/4MpNF6UgCoUGQ3zQtODCRemmYBdVaEWrwVpKUXAlSDeZe5uYVNTMYOaR5JSrLkzjRCv0cpbnx3f4zncu8Ftw7bqsQyHXhgkPVOPdyXr41ejbe9zMal15FzJEtRrIDnQfjT3jqpeH6D8qy5Bf/JCLjh8+HWY3gaueq8EhD/ND5skjc301vzCf6XzAgsBVegVYARYgSQCuBI6ej2T7e5IAWg1ldaRy+HJSpcwHmc77xpvJ3MS48TqmT0f02As9Hk0139UIcJVUgT3MC9m+DkTEYhFPX6mEiPnPH/eH+pgfuEJdYIUyP6Tbm0qHBwJzHFGIxb3U78He4/dv060N7NzmK/IkA799w9ndORMvFBDRXFvhDUFjLs5DkmhwNUz1MB+YiWUBFwqnw5srn4x4NNvfpXnLbP+LJFyWkgD6VETAtoWOjYjH8+9SLY1i22F6ofLJwGFJn35prn9xfu6eWXXilr29mV9ayEVGz5PlygphQUg/vGfMzthb362vq9ZGwvqWsDbW7K0fxqtoqu0OryvLeUVCakGjICyVxW2IkoH5QSPAfKKhasJUysPSBZkNS5UJhf/5k1SF/wAV6/M9EOYMWgAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Cimbalino Windows Phone Toolkit" title="Cimbalino Windows Phone Toolkit" src="/static/f34d90efdad2ae897cf3674c291353d0/8a4e8/Cimbalino-Windows-Phone-Toolkit-150x150.png" srcSet="/static/f34d90efdad2ae897cf3674c291353d0/8a4e8/Cimbalino-Windows-Phone-Toolkit-150x150.png 150w" sizes="(max-width: 150px) 100vw, 150px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a>The Windows Phone Application Bar has been a true headache for developers since day one, given that this object is not a <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.frameworkelement(v=vs.105).aspx">FrameworkElement</a>.</p><p>What this means is that we are unable to apply Styles or Templates to an <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.applicationbar%28v=vs.105%29.aspx">ApplicationBar</a> object, but most important, we are unable to bind to its properties, something that is a big issue when you what to use <abbr title="Model View ViewModel">MVVM</abbr> pattern in you apps.</p><p>Surely <abbr title="Model View ViewModel">MVVM</abbr> is not a closed pattern, and as such there are alternatives to overcome this issue (like <a href="http://geekswithblogs.net/lbugnion/archive/2010/04/09/using-commands-with-applicationbarmenuitem-and-applicationbarbutton-in-windows-phone-7.aspx">this one</a> or <a href="http://geekswithblogs.net/lbugnion/archive/2010/06/08/two-small-issues-with-windows-phone-7-applicationbar-buttons-and.aspx">this one</a>)!</p><p>In my case, in order to access the ApplicationBar in my apps in a more ”<abbr title="Model View ViewModel">MVVM</abbr>‘ed” way, I created the <strong>ApplicationBarBehavior</strong> that you can find in the <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>!</p><p>This Behavior, when applied to a PhoneApplicationPage or it’s LayoutRoot element, allows to create and maintain a fully bindable Application Bar, and as such applying a more consistent <abbr title="Model View ViewModel">MVVM</abbr> pattern.</p><p>Here’s a small sample code for it:</p><pre><code class="language-xml">&lt;!-- remaining code --&gt;

&lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;Transparent&quot;&gt;
    &lt;i:Interaction.Behaviors&gt;
        &lt;cimbalino:ApplicationBarBehavior&gt;
            &lt;cimbalino:ApplicationBarIconButton Command=&quot;{Binding AddItemCommand, Mode=OneTime}&quot; IconUri=&quot;/Images/appbar.add.rest.png&quot; Text=&quot;add&quot; IsVisible=&quot;{Binding IsSelectionDisabled}&quot; /&gt;
            &lt;cimbalino:ApplicationBarIconButton Command=&quot;{Binding EnableSelectionCommand, Mode=OneTime}&quot; IconUri=&quot;/Images/appbar.manage.rest.png&quot; Text=&quot;select&quot; IsVisible=&quot;{Binding IsSelectionDisabled}&quot; /&gt;
            &lt;cimbalino:ApplicationBarIconButton Command=&quot;{Binding DeleteItemsCommand, Mode=OneTime}&quot; CommandParameter=&quot;{Binding SelectedItems, ElementName=ItemsMultiselectList}&quot; IconUri=&quot;/Images/appbar.delete.rest.png&quot; Text=&quot;delete&quot; IsVisible=&quot;{Binding IsSelectionEnabled}&quot; /&gt;
        &lt;/cimbalino:ApplicationBarBehavior&gt;
    &lt;/i:Interaction.Behaviors&gt;

    &lt;!-- remaining code --&gt;

&lt;/Grid&gt;

&lt;!-- remaining code --&gt;
</code></pre><p>In this small code sample we can see the ApplicationBarBehavior and in it, some ApplicationBarIconButton (like you would do in the current one), and quickly we notice some new properties like <strong>Command</strong>, <strong>CommandParamenter</strong>, and <strong>IsVisible</strong> (something we can’t even find in the base Windows Phone ApplicationBar); obviously, even the properties <code>Text</code> and <code>IconUri</code> are bindable, allowing for easy localization! ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Updated: Reduce the size of your XAP/APPX package!]]></title>
            <link>https://www.pedrolamas.com/2013/02/20/updated-reduce-the-size-of-your-xapappx-package/</link>
            <guid>https://www.pedrolamas.com/2013/02/20/updated-reduce-the-size-of-your-xapappx-package/</guid>
            <pubDate>Wed, 20 Feb 2013 17:09:25 GMT</pubDate>
            <content:encoded><![CDATA[<p>In my <a href="/2013/02/15/reduce-the-size-of-your-xapappx-package-time-to-take-out-the-trash/">previous post</a> I wrote about an issue with the current build process for Windows 8 and Windows Phone 8 apps, where the Xml Documentation would get bundled in the output packages (APPX and XAP).</p><p>A few days later, I started to get some comments over the internet regarding the need to add my fix to all projects in a solution in order to make it fully work, something that turned out to be a bit tedious…</p><p>I have now updated the original post with a new solution that will only require you to change the projects that actually have a package output! :)</p><p>Please check the <a href="/2013/02/15/reduce-the-size-of-your-xapappx-package-time-to-take-out-the-trash/">original post</a> and update your projects to match the new change!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduce the size of your XAP/APPX package: time to take out the trash!]]></title>
            <link>https://www.pedrolamas.com/2013/02/15/reduce-the-size-of-your-xapappx-package-time-to-take-out-the-trash/</link>
            <guid>https://www.pedrolamas.com/2013/02/15/reduce-the-size-of-your-xapappx-package-time-to-take-out-the-trash/</guid>
            <pubDate>Fri, 15 Feb 2013 15:55:49 GMT</pubDate>
            <content:encoded><![CDATA[<p><strong>Updated on 20/02/2013</strong></p><p>Before you even continue reading this article, I must just address a small warning: the following information has passed the <abbr title="Works On My Machine">WOMM</abbr> certification, and as such, this works on my machine…</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:200px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:96.66666666666666%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAFGklEQVQ4y02UaUzUVxTFL8gHqemnfrC1mlZTbVNjW0yatraNrU2jUdoChVkYQGq0QAUNLmmqFrc0GhFbENKylEVkF1QWQQHBGQnKIvsyOP9ZGAadgRl2nOX/3mlmoE1vcnLyvvzycu7JJSZIiWnDiWkCvJggIWaI2yD2rN3Cx89eZ6ZzNdxW+pxNZA0ya5GRmc7c46ZTKWLfxs3MePxVppUT04R4c91e8nAECRHT7yemjyZuTvNhT/3fYbrwY2wil7GZ5nk4BMBhBFwmwDUG95vP1M8yS6aDab7fywTZ23aAYIonjP5I0MuIABA3X125eJx8uCmhlltLAJeGwaWDuDDi6mq7w026VrZg6+Pztn4XHDrAMeDk1kIw47Fs7gY+/20leB3BdoJI7NtEC5fJmxmP1/HJfCsWe2AZbWa6oTqubLiOezV5vOZWDlofFPO2h6WA2M1tJhVjc51glowJ0RBfANho4QGRc3g3EdNG+DKtIpA9u6TBvBIL5ruuqvI0VN/8E+2qa1zoK0PPowKo6rMw3FXMjepKVJRcxUBHiRMuFRyGhC6XoPga5kgfGNcSYU5FoiGuCjOFmNCVOVsa0tGuzOS9rVlgtkpgpgqYqwafqgQW7sAwkM/rbv3Bm2rT8Lj5b4fLnANrT0QBkE7AXW8SNRJ/bjox4DTn4mZJIvsr9Ry3anOB+RJgugiYKlzStNsLgLkSiJMF6HiQzIvyzvMZQwbsuqPd5nb/7S71N0Qu9Z73Mf7rrH08HR3NF1mXMhGYzoSxPxXV5cm4V5WGxpqraKlPRm9rKh7fTwKsGZjVp2JSk8YwlQHbQNzU+fiNHxlVn7kzVCSwsV+cMCcBtisc5ssctiR0NF1Cfs5llBYkofhaIiqKLiEz/XcoaxMB6xWw51c4LBc51++HfTjQ1Vm98yQgEjFNoB8zxE4y02mIYwmMmRIASwKGH8ZDdTsGbXUxUN6KwtDDI8jJuIDxvrPA+M/go3EQBTmDXoKJziBrWMAbEnIPE6RyZogys9F4DtNR/kI4ymH4ARgNAXQScK0UGJPCPiJHS2UkoFMAo1IsDodyJsg4dDI2+SRwJuPCh4fdnSYY9hETZDdg2IfZoShnRW40Gm9E8dnBSECvAAxyTHaH44U6DAtDYbD1RqC7IYoXZcVi9NFeEc9C0VS0o4mI/GCLcG85eJVLIz8NQ6jR1CaH8mYkq8iLQWn2QdwpPsi7G6JRlh2Fxoo41BbH8LKcWBRkHkJmSixTKyMw0xtkLkrZVrxmte+Gj/1ecWcYQmL/e16iRtoFvUxcHJaJQ81h/HZ+DE9PPozS7J94Q9kBNJbH8Ny0A7hffoCPKBXc0qUQuVbOBut3q4noCyLyXc5Q5s7xZa6VbRIFqQo6GWCQ2ecG5NzcGcq0LWEewFSvglueyJhdLedMkDphUeBJ9c5e/x1rond/+dpbkcHrKSLoTVo+O1KCzgMOFAVpMhOkgE7KYJABozIOowzQu13uWRLXynA78/O7KWe2niWidUE7X6d9Ieu9AO0SUNRI3O6zDN/KBGkkE6RNzhGp0fVUKtrVEoddLRHn+oOn1Pf3tBUmf5JyMHxjIBG9BMBrle8Kr6STH9Cp2HeXgLDGENd6frjC7VzrAfstDAavWxwKOaVV+u8ytwecSTi0eWtd3vbtROR17sgWb09NluerT1fTvz30aAn0n1a4oZaOAFocCqGx1m8J05HUW7eLnCMSzw0df/zdEmjbavr//ANbFwSxL6pVfgAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Works on my machine" title="Works on my machine" src="/static/629e3e3cd1943d6e5338810e3f71e8ba/772e8/Works-on-my-machine.png" srcSet="/static/629e3e3cd1943d6e5338810e3f71e8ba/e9ff0/Works-on-my-machine.png 180w,/static/629e3e3cd1943d6e5338810e3f71e8ba/772e8/Works-on-my-machine.png 200w" sizes="(max-width: 200px) 100vw, 200px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>Recently, while browsing <a href="http://stackoverflow.com/">StackOverflow</a> as I normally do, I found a <a href="http://stackoverflow.com/questions/14849374/visual-studio-packs-into-wp8-xap-unnecessary-xml-doc-files">question</a> that really caught my attention:</p><blockquote><p><strong>Visual Studio packs into <abbr title="Windows Phone 8">WP8</abbr> XAP unnecessary <abbr title="Extensible Markup Language">XML</abbr> doc files</strong></p><p>If you create Windows Phone 8 App in Visual Studio and reference any libs with <abbr title="Extensible Markup Language">XML</abbr> documentation files supplied from nuget or manually, Visual Studio will automatically pack those <abbr title="Extensible Markup Language">XML</abbr> files into output XAP as well.</p><p>In our case this weird behavior of Visual Studio increases XAP size almost twice. (We have 8Mb of xml docs in total.)</p><p>There is no such problem for <abbr title="Windows Phone 7">WP7</abbr> app projects.</p></blockquote><p>After reading this, I had to confirm this behavior myself! Here’s what I did:</p><ul><li>Created a blank solution</li><li>Added two Windows Phone projects, one with the 7.1 <abbr title="Software Development Kit">SDK</abbr> and the other with the 8.0.</li><li>Used NuGet to add <a href="http://nuget.org/packages/Newtonsoft.Json/">Json.net</a> package to both projects</li><li>Build the solution</li></ul><p>These are the XAP files resulting from building each project:</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:237px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:36.11111111111111%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAA60lEQVQY042PYW+DIBCG/f+/bcuSWusUaAoVZCoKKlbKoYtdlzR+WPZ8uty9d08u8h48wLKx/gGE5e5h14zazmSYkgvXvV3XNYSwvBBC+Ml5CGfKmWgemacq2gber/8AQoDfW0+zc27ohzNGeZrTC82yT5zjYxwnccooY5TtvnG3myhLXlzrWkXzPLdKta2SopSl5LwgiEgpm6atq4qx697vvel7Y/Qw2G3ZaE1Qnh5TjHByOiaHJI4P728fKEcEkxfzVk52LDgXgn9VTQQA1k7Ozb02utNad1LIcRwnO7VK1XWzN4OfHzh3/wZ+npCc0GW/DAAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Windows Phone XAP files from both projects" title="Windows Phone XAP files from both projects" src="/static/30db7bcdc2036ac04d72cae9e8efe3a6/008e2/Windows-Phone-XAP-files-from-both-projects.png" srcSet="/static/30db7bcdc2036ac04d72cae9e8efe3a6/e9ff0/Windows-Phone-XAP-files-from-both-projects.png 180w,/static/30db7bcdc2036ac04d72cae9e8efe3a6/008e2/Windows-Phone-XAP-files-from-both-projects.png 237w" sizes="(max-width: 237px) 100vw, 237px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>As you can see here, the <abbr title="Windows Phone 8">WP8</abbr> version is about 60Kb larger than the <abbr title="Windows Phone 7">WP7</abbr> version. <strong>That’s 42% larger!!!</strong></p><p>Here is the content of the <abbr title="Windows Phone 7">WP7</abbr> XAP file:</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:386px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:42.22222222222223%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAA7DAAAOwwHHb6hkAAABKklEQVQY022R2WrEMAxF/f9/VehroYUyiTfZjmM7i5OZzAZJHLvNhFkovQiBHnR0JSFbGs7lOM5LWEJYwrLGHMIcwjRveY4ptXVjbBVT6rynhDAOWpdIfr5LoEpprQpbWmecs9USU3yJlFLTNN53KaVlWet936uiRKoo8zwjGJOcChCFUsfDMb0o3rr7rnPOPsrr5eycQ/zjjey+BQhTWsGFcy79p7qu+q7faGk132pjkFKKYiyFUFIC44yytmkfE7Y8DAOl1Hu/gaZxFAKMc0hXHXBgjOVZDowLgPPpemt7jp3nCThUVfXA1c4KWaAv0IQyRpgEkEIqIXGGN4fxDogxWmOGw5Du1N57XRrU9XtCSI4xyTBdMZRTPo3Tn52ttcY+D3Y5n35f9QNjQcDkl096xQAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Windows Phone 7 XAP contents" title="Windows Phone 7 XAP contents" src="/static/095934772061ce76702887b4dca03b03/7bc0b/Windows-Phone-7-XAP-contents.png" srcSet="/static/095934772061ce76702887b4dca03b03/e9ff0/Windows-Phone-7-XAP-contents.png 180w,/static/095934772061ce76702887b4dca03b03/f21e7/Windows-Phone-7-XAP-contents.png 360w,/static/095934772061ce76702887b4dca03b03/7bc0b/Windows-Phone-7-XAP-contents.png 386w" sizes="(max-width: 386px) 100vw, 386px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>And this is the content of the <abbr title="Windows Phone 8">WP8</abbr> XAP file:</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:386px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:37.222222222222214%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAA/UlEQVQY02WQ227DIAyGef9321XVqQFDiB2ggdCpB7U5wpRky6TO/u0Ly98vy8wQAqiuH6ZpGsdV04+Gcetjytk3vjYu5RzbKLiQUhHW7HH5sKaqazunnNOSaak/5Zz7fkCixoec10lKhGStY7W1nHPBhQKFFTprX88u/4sYo3NuhRe/++2KRIxcCyAJUa+BGmMb96Wt325XKWUIYTMa+r7SlbGWNb4FLnSpdalLqZQqDZmN2eFLjIfDwXv/O5wJqTaGmXNQABJkcSp4UQghHvfn283zNJaqtM7udr4566pi7eVLApyK4nT8BAFKLW+c5/mNb86ND2GH++6FSN/SUopcd2/6rAAAAABJRU5ErkJggg==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="Windows Phone 8 XAP contents" title="Windows Phone 8 XAP contents" src="/static/7ba04d28fe5329d553edf4789d48b425/7bc0b/Windows-Phone-8-XAP-contents.png" srcSet="/static/7ba04d28fe5329d553edf4789d48b425/e9ff0/Windows-Phone-8-XAP-contents.png 180w,/static/7ba04d28fe5329d553edf4789d48b425/f21e7/Windows-Phone-8-XAP-contents.png 360w,/static/7ba04d28fe5329d553edf4789d48b425/7bc0b/Windows-Phone-8-XAP-contents.png 386w" sizes="(max-width: 386px) 100vw, 386px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>If you look closely on the <abbr title="Windows Phone 8">WP8</abbr> version above, you’ll see a <code>Newtonsoft.Json.xml</code> file - that’s the Json.net Xml Documentation!</p><p>What is it doing there? Nothing. Can we safely remove it? Most definitely, yes!</p><p>My research on why this only happens in Windows Phone 8 lead to the MSBuild process, specifically the <code>ResolveAssemblyReferences</code> task on <code>Microsoft.Common.targets</code> file: this particular task returns a variable called <code>ReferenceCopyLocalPaths</code>, referring to “Paths to files that should be copied to the local directory.” which upon inspection, proved to have our “garbage files”!</p><p>To fix this, edit the *.csproj files for your projects that have package outputs (XAP or APPX), and add this to the end of the file, just before the <code>&lt;/Project&gt;</code> closing tag:</p><pre><code class="language-xml">&lt;PropertyGroup&gt;
  &lt;FilesToXapDependsOn&gt;$(FilesToXapDependsOn);BeforeFilesToXap&lt;/FilesToXapDependsOn&gt;
&lt;/PropertyGroup&gt;
&lt;Target Name=&quot;BeforeFilesToXap&quot;&gt;
  &lt;ItemGroup&gt;
    &lt;FilteredPackagingOutputs Remove=&quot;@(FilteredPackagingOutputs)&quot; Condition=&quot;&#x27;%(FilteredPackagingOutputs.OutputGroup)&#x27; == &#x27;CopyLocalFilesOutputGroup&#x27; AND &#x27;%(FilteredPackagingOutputs.Extension)&#x27; == &#x27;.xml&#x27;&quot;/&gt;
  &lt;/ItemGroup&gt;
&lt;/Target&gt;
</code></pre><p>This custom target will run just before the <code>FilesToXap</code> target, telling MSBuild to remove all <abbr title="Extensible Markup Language">XML</abbr> Documentation files from the list of files to copy.</p><p>So far this has proven to work perfectly for my applications, and when I applied it to my <abbr title="Windows Phone 8">WP8</abbr> test project, I managed to get a much more reasonable 174KB XAP file!</p><p>One final note: although this article focus on Windows Phone, I actually found out that <strong>Windows Store Apps are also affected by this issue</strong>, and that the same solution can be used to fix the problem!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Error: Nuget.exe exited with code -1073741819]]></title>
            <link>https://www.pedrolamas.com/2013/02/04/error-nuget-exe-exited-with-code-1073741819/</link>
            <guid>https://www.pedrolamas.com/2013/02/04/error-nuget-exe-exited-with-code-1073741819/</guid>
            <pubDate>Mon, 04 Feb 2013 20:06:21 GMT</pubDate>
            <content:encoded><![CDATA[<p>Lately I’ve been getting more and more this type of error from <a href="http://nuget.org">Nuget</a> Package Restore when building my apps:</p><p><a href="/99b25a9b5e0913bba8f386920987a117/NuGet-1073741819-error.png"><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:680px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:17.22222222222222%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAIAAAAcOLh5AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAk0lEQVQI1yXGCQrCMBBA0Z5EUGiEzkwmtmnTmq5ZJqj3v49U4cN/lfh53cJ+JGvtw7AxLbMhzUTM2ugT+tcfDIBK3etaKXWvDtsN41SyxJhizEWK5JKTSJbX+yNSUkzLso7j5Jzr+2HoHZFmNghYXa63tu1CiP4555RCiOu251y89wCISADYNIBECITnNSIxGwD8AoVLJYkOVrZ3AAAAAElFTkSuQmCC&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="NuGet -1073741819 error" title="NuGet -1073741819 error" src="/static/99b25a9b5e0913bba8f386920987a117/c5bb3/NuGet-1073741819-error.png" srcSet="/static/99b25a9b5e0913bba8f386920987a117/e9ff0/NuGet-1073741819-error.png 180w,/static/99b25a9b5e0913bba8f386920987a117/f21e7/NuGet-1073741819-error.png 360w,/static/99b25a9b5e0913bba8f386920987a117/c5bb3/NuGet-1073741819-error.png 680w" sizes="(max-width: 680px) 100vw, 680px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></a></p><p>This seems to be a completely random issue with Nuget, as I see it happening with different projects, and sometimes not even happening at all!</p><p>Problem is that I work with some big/complex solutions that have a lot of projects, each one with it’s own <code>packages.config</code> file that can show this issue, so that sums up to <strong>a lot of failed builds!</strong></p><p>There are actually a <a href="http://nuget.codeplex.com/workitem/2593">few</a> <a href="http://nuget.codeplex.com/workitem/2064">open</a> tickets about this in <a href="http://nuget.codeplex.com/">Codeplex</a>, but given that this issue has been reported a while ago and so far it has not been solved, I thought on tackle this myself!</p><h2>“If at first you don’t succeed, try and try again”</h2><p>Following that motto, I thought on changing the Nuget Package Restore process so that it will retry a few times before aborting the build!</p><p>The easiest way I found to achieve this goal is just to change the <code>.nuget\NuGet.targets</code> file on the root of the solution. Inside this file, I found the following:</p><pre><code class="language-xml">&lt;Target Name=&quot;RestorePackages&quot; DependsOnTargets=&quot;CheckPrerequisites&quot;&gt;
    &lt;Exec Command=&quot;$(RestoreCommand)&quot;
          Condition=&quot;&#x27;$(OS)&#x27; != &#x27;Windows_NT&#x27; And Exists(&#x27;$(PackagesConfig)&#x27;)&quot; /&gt;

    &lt;Exec Command=&quot;$(RestoreCommand)&quot;
          LogStandardErrorAsError=&quot;true&quot;
          Condition=&quot;&#x27;$(OS)&#x27; == &#x27;Windows_NT&#x27; And Exists(&#x27;$(PackagesConfig)&#x27;)&quot; /&gt;
&lt;/Target&gt;
</code></pre><p>Above you can see the MSBuild target that actually runs <code>Nuget.exe</code>, and so this is the one I will change to “fix” the issue.</p><p>This is my improved <code>RestorePackages</code> target:</p><pre><code class="language-xml">&lt;Target Name=&quot;RestorePackages&quot; DependsOnTargets=&quot;CheckPrerequisites&quot; Condition=&quot;Exists(&#x27;$(PackagesConfig)&#x27;)&quot;&gt;
    &lt;PropertyGroup&gt;
        &lt;NugetLogStandardErrorAsError Condition=&quot;&#x27;$(OS)&#x27; == &#x27;Windows_NT&#x27;&quot;&gt;true&lt;/NugetLogStandardErrorAsError&gt;
        &lt;NugetLogStandardErrorAsError Condition=&quot;&#x27;$(OS)&#x27; != &#x27;Windows_NT&#x27;&quot;&gt;false&lt;/NugetLogStandardErrorAsError&gt;
    &lt;/PropertyGroup&gt;

    &lt;Exec Command=&quot;$(RestoreCommand)&quot; LogStandardErrorAsError=&quot;$(NugetLogStandardErrorAsError)&quot; IgnoreExitCode=&quot;True&quot;&gt;
        &lt;Output TaskParameter=&quot;ExitCode&quot; PropertyName=&quot;ExitCode&quot; /&gt;
    &lt;/Exec&gt;

    &lt;Message Text=&quot;Error occurred, #1 retry...&quot; Importance=&quot;High&quot; Condition=&quot; $(ExitCode) != 0 &quot; /&gt;

    &lt;Exec Command=&quot;$(RestoreCommand)&quot; LogStandardErrorAsError=&quot;$(NugetLogStandardErrorAsError)&quot; IgnoreExitCode=&quot;True&quot; Condition=&quot; $(ExitCode) != 0 &quot;&gt;
        &lt;Output TaskParameter=&quot;ExitCode&quot; PropertyName=&quot;ExitCode&quot; /&gt;
    &lt;/Exec&gt;

    &lt;Message Text=&quot;Error occurred, #2 and last retry...&quot; Importance=&quot;High&quot; Condition=&quot; $(ExitCode) != 0 &quot; /&gt;

    &lt;Exec Command=&quot;$(RestoreCommand)&quot; LogStandardErrorAsError=&quot;$(NugetLogStandardErrorAsError)&quot; Condition=&quot; $(ExitCode) != 0 &quot; /&gt;
&lt;/Target&gt;
</code></pre><p>You can see three consecutive <code>Exec</code> tasks here, each one will run depending on the previous one exit code, and only the last one will actually abort the build.</p><p>What this means is that if Nuget fails, we will retry it two more times before aborting the build!</p><p>As you can see, this is not a proper fix for the issue, it just bypasses it… so I’m still waiting for a fix on this - and I’m now looking at you, Nuget dev team! ;)</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The FrameworkElement.Language property and why should you care!]]></title>
            <link>https://www.pedrolamas.com/2013/01/16/the-frameworkelement-language-property-and-why-should-you-care/</link>
            <guid>https://www.pedrolamas.com/2013/01/16/the-frameworkelement-language-property-and-why-should-you-care/</guid>
            <pubDate>Wed, 16 Jan 2013 15:48:43 GMT</pubDate>
            <content:encoded><![CDATA[<p>The first time I came aware of this issue was when reading a post by Portuguese <abbr title="Most Valuable Professional">MVP</abbr> <a href="http://paulomorgado.net/">Paulo Morgado</a> on the App Hub Forums:</p><blockquote><p>If all the emulator settings are set to “Portuguese (Portugal)” (both interface as all regional settings), how come when I use an <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.data.ivalueconverter(v=vs.105).aspx">IValueConverter</a> on any Binding expression, the “culture” parameter has a “en-US” <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.globalization.cultureinfo(v=vs.105).aspx">CultureInfo</a>?…</p></blockquote><p>To properly research on the subject, I created a small app with two TextBlock controls that show the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.threading.thread.currentculture(v=vs.105).aspx">Thread.CurrentThread.CurrentCulture</a> and <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.threading.thread.currentuiculture(v=vs.105).aspx">Thread.CurrentThread.CurrentUICulture</a> current values, and a third TextBlock with an IValueConverter that basically returns the culture.Name he is using, and the result was quite surprising!</p><p>Here is the code for my CultureDebugValueConverter class, implementing an IValueConverter:</p><pre><code class="language-csharp">public class CultureDebugValueConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return culture.Name;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
</code></pre><p>Notice that no conversion is actually being made (the value parameter isn’t even being used), it just returns the “culture.Name” value from it.</p><p>Here’s the main ContentPanel on the MainPage.xaml:</p><pre><code class="language-xml">&lt;StackPanel x:Name=&quot;ContentPanel&quot; Grid.Row=&quot;1&quot; Margin=&quot;12,0,12,0&quot;&gt;
    &lt;TextBlock Style=&quot;{StaticResource PhoneTextSubtleStyle}&quot;&gt;CurrentCulture&lt;/TextBlock&gt;
    &lt;TextBlock Text=&quot;{Binding CurrentCulture}&quot; Style=&quot;{StaticResource PhoneTextTitle2Style}&quot; /&gt;
    &lt;TextBlock Style=&quot;{StaticResource PhoneTextSubtleStyle}&quot;&gt;CurrentUICulture&lt;/TextBlock&gt;
    &lt;TextBlock Text=&quot;{Binding CurrentUICulture}&quot; Style=&quot;{StaticResource PhoneTextTitle2Style}&quot; /&gt;
    &lt;TextBlock Style=&quot;{StaticResource PhoneTextSubtleStyle}&quot;&gt;Converter Culture&lt;/TextBlock&gt;
    &lt;TextBlock Text=&quot;{Binding Converter={StaticResource CultureDebugValueConverter}}&quot; Style=&quot;{StaticResource PhoneTextTitle2Style}&quot; /&gt;
&lt;/StackPanel&gt;
</code></pre><p>As you can see, the last TextBlock just sets the Binding.Converter to a StaticResource of CultureDebugValueConverter type.</p><p>This is the remaining code placed on MainPage.xaml.cs:</p><pre><code class="language-csharp">public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        this.DataContext = this;
    }

    public string CurrentCulture
    {
        get
        {
            return Thread.CurrentThread.CurrentCulture.Name;
        }
    }

    public string CurrentUICulture
    {
        get
        {
            return Thread.CurrentThread.CurrentUICulture.Name;
        }
    }
}
</code></pre><p>Finally, I started the emulator, changed all the regional settings to “Portuguese (Portugal), and this is what I got after running the app:</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:300px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:75%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAIDBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAcWKsA//xAAYEAADAQEAAAAAAAAAAAAAAAABEBEiMf/aAAgBAQABBQKiZR4v/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGRAAAQUAAAAAAAAAAAAAAAAAkQABIDFB/9oACAEBAAY/AtKpzH//xAAYEAADAQEAAAAAAAAAAAAAAAAQETEAUf/aAAgBAQABPyHhnGokGf/aAAwDAQACAAMAAAAQoA//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAdEAACAgEFAAAAAAAAAAAAAAABESExEABBUWGR/9oACAEBAAE/EAGbaFE1qJYp7eYEg/AXO2f/2Q==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="LanguageTestApp original version" title="LanguageTestApp original version" src="/static/5aefddada98c7782e4cb95e7348acefc/f93b5/LanguageTestApp-original-version.jpg" srcSet="/static/5aefddada98c7782e4cb95e7348acefc/4ec73/LanguageTestApp-original-version.jpg 180w,/static/5aefddada98c7782e4cb95e7348acefc/f93b5/LanguageTestApp-original-version.jpg 300w" sizes="(max-width: 300px) 100vw, 300px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>So the real question right now is: If the operating system interface, the CurrentCulture, and the CurrentUICulture are all set to “pt-PT”, from where did that “en-US” came from?</p><p>There is no trivial reason for this behavior, and to completely understand it, we first need to know how the “culture” parameter on <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.data.ivalueconverter.convert(v=vs.105).aspx">IValueConverter.Convert</a> method works; on the documentation, you can read the following: * The culture is determined in the following order:</p><ul><li>The converter looks for the ConverterCulture property on the Binding object.</li><li>If the ConverterCulture value is null, <strong>the value of the Language property is used.</strong></li></ul><p>Given that I didn’t set the Binding.ConverterCulture property, this means it will fallback to the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.frameworkelement.language(v=vs.105).aspx">FrameworkElement.Language</a>, which in turn has this in the docs:</p><p>The default is an XmlLanguage object that has its IetfLanguageTag value set to the string “en-US”**</p><p><strong>We have finally found the “guilty” one!!!</strong></p><p>Now that we know this, we can fix it just by setting the Page.Language property! The fixed code should look something like this:</p><pre><code class="language-csharp">public MainPage()
{
    Language = System.Windows.Markup.XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentUICulture.Name);

    InitializeComponent();

    this.DataContext = this;
}
</code></pre><p>If you look closely on the 3rd line, you’ll see the Language property set to a XmlLanguage instance created with the CurrentUICulture.Name.</p><p>Be aware that for this to work, you must set the Language property <strong>before</strong> the InitializeComponent method gets invoked!</p><p>And here’s the final result:</p><p><span class="gatsby-resp-image-wrapper" style="position:relative;display:block;margin-left:auto;margin-right:auto;max-width:300px">
      <span class="gatsby-resp-image-background-image" style="padding-bottom:75%;position:relative;bottom:0;left:0;background-image:url(&#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAIDBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAcWKsA//xAAYEAADAQEAAAAAAAAAAAAAAAABEBEiMf/aAAgBAQABBQKiZR4v/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGRAAAQUAAAAAAAAAAAAAAAAAkQABIDFB/9oACAEBAAY/AtKpzH//xAAYEAADAQEAAAAAAAAAAAAAAAAQETFRAP/aAAgBAQABPyHDPGokHh//2gAMAwEAAgADAAAAEIAP/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAHRAAAgIBBQAAAAAAAAAAAAAAESEBMRAAQVFhkf/aAAgBAQABPxCIXLSQBGlLA+3mF5ULe2f/2Q==&#x27;);background-size:cover;display:block"></span>
  <img class="gatsby-resp-image-image" alt="LanguageTestApp fixed version" title="LanguageTestApp fixed version" src="/static/3fa636ea09b76dcf7f45616add7131f4/f93b5/LanguageTestApp-fixed-version.jpg" srcSet="/static/3fa636ea09b76dcf7f45616add7131f4/4ec73/LanguageTestApp-fixed-version.jpg 180w,/static/3fa636ea09b76dcf7f45616add7131f4/f93b5/LanguageTestApp-fixed-version.jpg 300w" sizes="(max-width: 300px) 100vw, 300px" style="width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0" loading="lazy" decoding="async"/>
    </span></p><p>I honestly don’t know the reason for this strange behavior, but this is a problem to account for if you have localization needs for your Windows Phone app!</p><p>The demo project I created and used for this article can be downloaded from <a href="/2893cf43b54e6c658a071860ee87aba1/PedroLamas.LanguageTestApp.zip">here</a>!</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to force a focused Textbox binding to update when I tap an app bar item]]></title>
            <link>https://www.pedrolamas.com/2013/01/11/how-to-force-a-focused-textbox-binding-to-update-when-i-tap-an-app-bar-item/</link>
            <guid>https://www.pedrolamas.com/2013/01/11/how-to-force-a-focused-textbox-binding-to-update-when-i-tap-an-app-bar-item/</guid>
            <pubDate>Fri, 11 Jan 2013 17:11:24 GMT</pubDate>
            <content:encoded><![CDATA[<p>If you have <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.textbox(v=vs.105).aspx">TextBox</a> controls in your app and you’re binding to the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.windows.controls.textbox.text(v=vs.105).aspx">Text</a> property (two-way mode), you should by now have noticed that the binding source isn’t updated when you tap an icon or menu item in the app bar!</p><p>The first thing you need to know in order to understand why this is happening, is that the TextBox control only updates the Text binding source when the control looses focus.</p><p>Second reason is that the <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.applicationbar(v=vs.105).aspx">ApplicationBar</a> control can’t get focus, nor can it’s <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.applicationbariconbutton(v=vs.105).aspx">ApplicationBarIconButton</a> or <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.applicationbarmenuitem(v=vs.105).aspx">ApplicationBarMenuItem</a> controls, so when you tap on them, the click event will be invoked without the TextBox control ever loosing focus!</p><p>To fix this behavior we need to force an update on the binding source when the click event get’s invoked, and here’s some code on how to achieve this:</p><pre><code class="language-csharp">var focusedElement = FocusManager.GetFocusedElement();
var focusedTextBox = focusedElement as TextBox;

if (focusedTextBox != null)
{
    var binding = focusedTextBox.GetBindingExpression(TextBox.TextProperty);

    if (binding != null)
    {
        binding.UpdateSource();
    }
}
</code></pre><p>We start by using <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc190472(v=vs.105).aspx">FocusManager.GetFocusedElement</a> method to get the current focused element. Then we check if that is a TextBox control, and if so, force it to update the Text property binding source!</p><p>The same problem will happen with <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/system.windows.controls.passwordbox(v=vs.105).aspx">PasswordBox</a>, so it’s best just to handle both situations and encapsulate this in a reusable method:</p><pre><code class="language-csharp">public static void FocusedTextBoxUpdateSource()
{
    var focusedElement = FocusManager.GetFocusedElement();
    var focusedTextBox = focusedElement as TextBox;

    if (focusedTextBox != null)
    {
        var binding = focusedTextBox.GetBindingExpression(TextBox.TextProperty);

        if (binding != null)
        {
            binding.UpdateSource();
        }
    }
    else
    {
        var focusedPasswordBox = focusedElement as PasswordBox;

        if (focusedPasswordBox != null)
        {
            var binding = focusedPasswordBox.GetBindingExpression(PasswordBox.PasswordProperty);

            if (binding != null)
            {
                binding.UpdateSource();
            }
        }
    }
}
</code></pre><p>All you now need is to call the <code>FocusedTextBoxUpdateSource</code> method in the start of the app bar item control click event handler so that it will update the binding source before the rest of the code runs!</p><p>You can find this problem fixed on some toolkits and frameworks, like <a href="http://caliburnmicro.codeplex.com">Caliburn.Micro</a> and my own <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a> <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit%20(WP71)/Behaviors/ApplicationBarItemBase.cs">ApplicationBarBehavior</a>.</p><p>Another way to fix this would be by updating the binding source on text changed rather than when it looses focus, and for that you can use the <a href="http://coding4fun.codeplex.com/SourceControl/changeset/view/78171#1210643">TextBinding</a> helper from <a href="http://coding4fun.codeplex.com/">Coding4Fun Toolkit for Windows Phone</a>.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Phone Choosers with async/await]]></title>
            <link>https://www.pedrolamas.com/2013/01/08/windows-phone-choosers-with-asyncawait/</link>
            <guid>https://www.pedrolamas.com/2013/01/08/windows-phone-choosers-with-asyncawait/</guid>
            <pubDate>Tue, 08 Jan 2013 12:04:04 GMT</pubDate>
            <content:encoded><![CDATA[<p>Currently, Windows Phone <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769542(v=vs.105).aspx#BKMK_Choosers">Choosers</a> work is by invoking the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff707460(v=vs.105).aspx">Show</a> method and then subscribing the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff707989(v=vs.105).aspx">Completed</a> event and waiting for it to be invoked.</p><p>Wouldn’t it be great to just use <code>await chooser.ShowAsync()</code> and get the results immediately?</p><p>All choosers extend the <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff707923(v=vs.105).aspx">ChooserBase&lt;TTaskEventArgs&gt;</a> class, and it’s exactly for this class that we are going to use to create a ShowAsync extension method.</p><p>We start by creating the extension method signature:</p><pre><code class="language-csharp">public static class ExtensionMethods
{
    public static Task&lt;TTaskEventArgs&gt; ShowAsync&lt;TTaskEventArgs&gt;(this ChooserBase&lt;TTaskEventArgs&gt; chooser)
        where TTaskEventArgs : TaskEventArgs
    {
    }
}
</code></pre><p>The <code>async</code> methods are required to return void, <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/system.threading.tasks.task(v=vs.105).aspx">Task</a>, or <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/dd321424(v=vs.105).aspx">Task&lt;TResult&gt;</a> in order to be invoked with the <code>await</code> keyword. So our method will return a <code>Task&lt;TTaskEventArgs&gt;</code> value, where the <code>TTaskEventArgs</code> generic type must be a <a href="http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.tasks.taskeventargs(v=vs.105).aspx">TaskEventArgs</a> subtype.</p><p>We will need to use a <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/dd449174(v=vs.105).aspx">TaskCompletionSource</a> object so we can return a Task and later on set the result of the asynchronous operation.</p><pre><code class="language-csharp">var taskCompletionSource = new TaskCompletionSource&lt;TTaskEventArgs&gt;();
</code></pre><p>Next we will add the code for the normal Chooser handling:</p><pre><code class="language-csharp">EventHandler&lt;TTaskEventArgs&gt; completed = null;

completed = (s, e) =&gt; {
    chooser.Completed -= completed;

    taskCompletionSource.SetResult(e);
};

chooser.Completed += completed;
chooser.Show();
</code></pre><p>Notice that we are removing the event handler after it gets invoked as not to have a memory leak! All that is missing now is just returning the Task object:</p><pre><code class="language-csharp">return taskCompletionSource.Task;
</code></pre><p>And that’s it!</p><p>Here’s how the full extension method should look:</p><pre><code class="language-csharp">public static class ExtensionMethods {
    public static Task&lt;TTaskEventArgs&gt; ShowAsync&lt;TTaskEventArgs&gt;(this ChooserBase&lt;TTaskEventArgs&gt; chooser)
        where TTaskEventArgs : TaskEventArgs
    {
        var taskCompletionSource = new TaskCompletionSource&lt;TTaskEventArgs&gt;();

        EventHandler&lt;TTaskEventArgs&gt; completed = null;

        completed = (s, e) =&gt; {
            chooser.Completed -= completed;

            taskCompletionSource.SetResult(e);
        };

        chooser.Completed += completed;
        chooser.Show();

        return taskCompletionSource.Task;
    }
}
</code></pre><p>You can download a sample code for this directly from the <a href="https://code.msdn.microsoft.com/Windows-Phone-Choosers-99aeec4b">Microsoft Code Gallery</a>.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The PhoneApplicationFrame bug is still alive!]]></title>
            <link>https://www.pedrolamas.com/2013/01/07/the-phoneapplicationframe-bug-is-still-alive/</link>
            <guid>https://www.pedrolamas.com/2013/01/07/the-phoneapplicationframe-bug-is-still-alive/</guid>
            <pubDate>Mon, 07 Jan 2013 11:25:41 GMT</pubDate>
            <content:encoded><![CDATA[<p>This is an issue that I stomped about 6 months ago, <a href="http://www.pedrolamas.pt/2012/06/21/phoneapplicationframe-cangoback-navigationservice-cangoback/">blogged</a> about it, <a href="http://social.msdn.microsoft.com/forums/en-us/wpdevelop/thread/fbe3e38a-37ee-4d78-9eec-46ac7826d594">reported</a> and got it confirmed by Microsoft, and just found out that after all this time, they didn’t fix it on Windows Phone 8!!</p><p>When the Windows Phone <abbr title="Software Development Kit">SDK</abbr> started to allow developers to remove entries from the navigation back stack, they (inadvertly?) introduced a bug in <a href="http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationframe(v=vs.92).aspx">PhoneApplicationFrame</a>, more specifically in the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.frame.cangoback(v=vs.92).aspx">CanGoBack</a> property!</p><p>Here’s how to simulate the issue:</p><ul><li>Start by creating two separate pages</li><li>On the application start page, add a Button that when clicked will just navigate to the second page (thus adding an item to the navigation stack)</li><li>On the second page Loaded event, call the <a href="http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.removebackentry(v=vs.92).aspx">NavigationService.RemoveBackEntry</a> (removing the previously added item from the navigation stack)</li><li>Get the current PhoneApplicationFrame instance with <code>(PhoneApplicationFrame)App.Current.RootVisual</code></li><li>Compare the <a href="http://msdn.microsoft.com/en-us/library/system.windows.navigation.navigationservice.cangoback(v=vs.92)">NavigationService.CanGoBack</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.frame.cangoback(v=vs.92).aspx">PhoneApplicationFrame.CanGoBack</a> property values: the first indicates <code>false</code>, the correct and expected value, while the second indicates <code>true</code>, something that should not happen because we just cleared the navigation back stack when we removed the only entry that was there!!</li></ul><p>By using a Reflection tool to look at the PhoneApplicationFrame implementation, one could easily realize that while the methods Navigate, GoBack, RemoveBackEntry and others are just proxies to the same ones on NavigationService, this is not true for the CanGoBack and CanGoForward properties, which have local values and only get updated after a navigation event!</p><p>And this is where lies the whole problem: the values ​​of these properties should be obtained directly from NavigationService like the methods are, or at least they should also be updated when RemoveBackEntry method gets called!</p><p>You can test and confirm this bug by downloading <a href="/17d05e322da22d3df0e5d7f2848fc9b2/FrameBugSample.zip">this sample application</a>.</p><p>All you need to do is run the app, click on “Navigate to self”, check that the stack count is now 1, click on one of the two buttons for the “RemoveBackEntry” and realize that the CanGoBack properties now have different values!</p><p>This situation has been fixed in the implementation of the <a href="https://github.com/Cimbalino/Cimbalino-Phone-Toolkit/blob/master/src/Cimbalino.Phone.Toolkit%20(WP71)/Services/NavigationService.cs">INavigationService</a> on <a href="http://cimbalino.org">Cimbalino Windows Phone Toolkit</a>, but be aware that there are still a lot of similar services implementations from other toolkits and frameworks that have this bug…</p><p><strong>Updated on 20/01/2013:</strong> After a few tweets with <a href="http://dotnetbyexample.blogspot.com/">Joost van Schaik</a>, he updated the INavigationService implementation on <a href="http://wp7nl.codeplex.com/">Wp7nl utilities</a> to match the Cimbalino Windows Phone Toolkit.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome!]]></title>
            <link>https://www.pedrolamas.com/2013/01/05/welcome/</link>
            <guid>https://www.pedrolamas.com/2013/01/05/welcome/</guid>
            <pubDate>Sat, 05 Jan 2013 15:23:26 GMT</pubDate>
            <content:encoded><![CDATA[<p>My name is Pedro Lamas, I’m a Portuguese developer specialized in Microsoft Technologies, and this is my English blog for Windows and Windows Phone Development.</p><p>For a while this address was home for my Portuguese blog <a href="http://www.pedrolamas.pt">Nação do Cimbalino</a>. Rest assure that the blog still exists, it just got moved to a new address!</p><p>I’ll be working to get the blog up and running in the next few days, so please bare with me.</p><p>I promise it will be worth it! ;)</p>]]></content:encoded>
        </item>
    </channel>
</rss>