<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Joel Joseph]]></title><description><![CDATA[---------- Senior Lead Full Stack Software Engineer ----------
Angular | ReactJs | AngularJs | JavaScript | TypeScript | PHP | UWP | Xamarin | Ionic | Nodejs | C# | Java | .NET | Yii Framework | Azure]]></description><link>http://joeljoseph.net:80/</link><generator>Ghost 0.11</generator><lastBuildDate>Wed, 21 Aug 2024 01:07:56 GMT</lastBuildDate><atom:link href="http://joeljoseph.net:80/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Building good Team Process]]></title><description><![CDATA[The article will help you understand different phases for building a good  Development or Engineering team process]]></description><link>http://joeljoseph.net:80/building-good-team-process/</link><guid isPermaLink="false">b4991dc8-b92c-4413-a995-4bb3a7ec3576</guid><category><![CDATA[Team Building]]></category><category><![CDATA[Engineering]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sat, 19 Jun 2021 16:06:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2021/06/phases-for-building-good-team-process.png" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2021/06/phases-for-building-good-team-process.png" alt="Building good Team Process"><p>The article will help you understand different phases that I went through for building a good  <mark>Development / Engineering team process</mark> for solving company's Engineering needs.</p>

<p>Please do note that the information here is purely within the scope of my experience and people I interacted in my professional life. </p>

<p>Every term and terminology in the article are defined by me, which helps me to document my life experience in a simple way. You may take this as a case study and define your own process.</p>

<p>The term <mark>'Process'</mark> in this article refers to steps you follow, tools you use, the ways you take in planning things the end goal being to solve a problem by combining individual efforts into collective results</p>

<p><img src="http://joeljoseph.net:80/content/images/2021/06/1.png" alt="Building good Team Process"></p>

<p>In my case the main focus was on defining process for:</p>

<ul>
<li>Task Management</li>
<li>Communication and Collaboration </li>
<li>DevOps</li>
<li>Hiring new developers </li>
<li>Tools used</li>
</ul>

<h4 id="phasesandstages">Phases and Stages</h4>

<p><br> <br>
<strong>Stage One</strong> : The idea of this stage is, by the end of all the phases in this stage you will have a perfectly working process for your team. This stage is somewhat time consuming but most of the time it's a onetime investment for reaching your goal and hence it one of the important stage that may define your success</p>

<ul>
<li>Input gathering </li>
<li>Experimenting </li>
<li>Process Definition </li>
<li>Implementation</li>
</ul>

<p><strong>Stage Two</strong> : This stage is repeated over a period of cycles, for me it was every 6 month or yearly. This make sure that your process is improved by eliminating the bottlenecks</p>

<ul>
<li>Feedback and Review</li>
</ul>

<p><br></p>

<h5 id="inputgathering">Input Gathering</h5>

<p>This is the first phase where you start to observe and take note of the organisation and its requirements. Each and every organisation or company may have different working style and goals. You may have past experience in some other organisation and companies but you keep them aside and keep on observing how everything is currently working.</p>

<h5 id="experimenting">Experimenting</h5>

<p>Here you will start defining the initial process by studying the   data collected in input gathering phase and try to implement it with the help of your team. The process is experimented for short term and may start review of the process as soon as you reach a bottleneck. You may also try to learn from process that are followed in other companies or organisation</p>

<h5 id="processdefinition">Process Definition</h5>

<p>This phase comes after the experimenting phase and by this time you will have a working Process defined for your team. The idea is to document this process and make sure to educate your team on the process. Each member of your team should have clear understanding of the process and you will have to make sure that everyone follows this process </p>

<h5 id="implementation">Implementation</h5>

<p>This phase is infinite and here you will repeatedly follow the defined process and make sure that each and every one of your team follows it.  you may also define an onboarding process so that if there is a new addition to your team it will help them to get onboard in following the process quickly</p>

<h5 id="feedbackandreview">Feedback and Review</h5>

<p>This is implemented over a period of time in cycles and in my case it was every 6 month or yearly. Here you will take feedback on your current process and also review the do's and don'ts and after studying the data you will try to eliminate the bottlenecks that slows down your team. You will also be studying the result from your previous year looking into your success and failures and tweak your process to improve the results</p>]]></content:encoded></item><item><title><![CDATA[Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh]]></title><description><![CDATA[This article will hep you to deploy angular 6+ application  on apache server also to solve 404 not found error on page refresh.]]></description><link>http://joeljoseph.net:80/angular-6-deploy-on-apache-server-by-solving-404-not-found-error-on-page-refresh/</link><guid isPermaLink="false">7ab52921-4248-4862-b40f-0a621ad653a8</guid><category><![CDATA[Angular]]></category><category><![CDATA[Angular 6]]></category><category><![CDATA[Apache]]></category><category><![CDATA[Angular7]]></category><category><![CDATA[Angular6+]]></category><category><![CDATA[Angular-404-not-found]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Fri, 30 Nov 2018 14:08:02 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2018/11/IC806114.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2018/11/IC806114.jpg" alt="Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh"><p>This article will hep you to deploy <b>angular 6+</b> application  on <mark>apache server</mark> also to solve <b>404 not found</b> error on page refresh.</p>

<p><br>  </p>

<h5> Getting Started </h5>

<p>For now let's hope you have already setup a new Angular6+ project or has an existing Angular6+ project.Here we are considering working with an existing Angular6+ App. I have named my project as <mark>angular-deployemnt-sample</mark>.</p>

<p>The project was scaffolded using <a href="https://cli.angular.io/">Angular cli</a> which can be used to generate basic app structure for your projects. <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/11/angular-project-cli-generate-project.gif" alt="Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh"></p>

<p>After generating the basic app using <code>Cli</code> and setting up <mark>basic routing module</mark> and a <mark>home component</mark>  the project structure looks something like this <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/11/angular-basic-structure-with-routing.png" alt="Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh"></p>

<p>if you want to run the same in local just  use the command  </p>

<pre><code>ng serve --open  
</code></pre>

<p>The above command will start serving the  project at the url  </p>

<pre><code>http://localhost:4200/  
</code></pre>

<p><br></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/11/angular6-ng-serve-2.png" alt="Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh"></p>

<p><br>  </p>

<h5> Build app for production </h5>  

<p>Before deploying to the apache server we need to build the project and optimise it for production.</p>

<pre><code>ng build --prod  
</code></pre>

<p><br>  </p>

<h6>Setting our Base</h6>  

<p>To link around your application using relative links, you will need to set a <code>&lt;base&gt;</code> in the <code>&lt;head&gt;</code> of your document. while setting base you will have to consider   where the projects resides in the server</p>

<p>In <b>angular 6+ </b>cli allows you to set the base automatically while building the project.if your project files is placed in the <code>/var/www/html</code>  folder (that is  project files copied from dist folder after <mark>ng build --prod</mark> to root folder of your server) or you are running on <mark>ng serve</mark>  (while under development in local) then  your base should be</p>

<pre><code>&lt;base href="/"&gt;  
</code></pre>

<p>if your project files resides in some folder <mark>somefolder</mark>   then base should be</p>

<pre><code>&lt;base href="/somefolder/"&gt;  
</code></pre>

<p>To set the base during build to root folder <code>/var/www/html</code> you can use the regular command</p>

<pre><code>ng build --prod  
</code></pre>

<p>To set the base during build when  your project files resides in some folder <mark>somefolder</mark>   then use</p>

<pre><code>ng build --prod  --base-href somefolder  
</code></pre>

<p>Now after you copying the files from your <code>dist</code> folder to apache servers root folder <code>/var/www/html</code> the project will work until you refresh the page</p>

<h6>404 Not found error on page refresh</h6>  

<p>Now that you have deployed the project to server, and everything seems ok until you try to refresh the page . You will find that your app throws a <b> 404 Not found</b> error
<img src="http://joeljoseph.net:80/content/images/2018/11/angular-404-not-found-on-page-refresh.png" alt="Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh"></p>

<p><br>  </p>

<h6>Solution</h6>

<p>To solve this there are two approaches or strategy</p>

<ul>
<li><a href="https://angular.io/api/common/PathLocationStrategy">PathLocationStrategy  (or html5Mode)</a></li>
<li><a href="https://angular.io/api/common/HashLocationStrategy">HashLocationStrategy</a></li>
</ul>

<p><br></p>

<h6>We will use PathLocationStrategy</h6>

<p>The default strategy used in Angular is the <code>PathLocationStrategy</code> so we need to do nothing to enable it.  And this will be the statergy that we are going to use here</p>

<p>It takes advantage of a relatively new <mark>HTML5 API</mark> called <mark>pushstate</mark> (from the HTML5 history API).</p>

<p>By using <mark>pushstate</mark> we can change the <code>URL</code> and not have the browser request the page from the server and without needing to use a <mark>hash fragment</mark>.</p>

<p>Unfortunately it has one big downside, if we then reloaded the page or bookmarked and opened it later the browser would make a request to the server</p>

<p>By using a <mark>hash fragment</mark> the server never needs to know about any application <code>URL</code>, it will only ever get asked for the root page and it will only ever return the root page.</p>

<p>But by using a <code>PathLocationStrategy</code> the server needs to be able to return the main application code for every <code>URL</code>, not just the <code>root URL</code>.</p>

<p>So with <code>PathLocationStrategy</code> we need to co-operate with a server side that supports this functionality, it’s possible and quite easy to implement a server side like this but it does require some effort and cooperation.</p>

<p>When you have <code>html5Mode</code> enabled, the <code>#</code> character will no longer be used in your <code>URLs</code>. The <code>#</code> symbol is useful because it requires no server side configuration. Without <code>#</code>, the <code>URL</code> looks much nicer, but it also requires <mark>server side rewrites</mark>.</p>

<h6>Configuring Apache Server</h6>  

<p>we need to configure the server for <mark>rewrites</mark>, and this involve following steps</p>

<ul>
<li>Activate <code>mod_rewrite</code></li>
<li>Edit Apache configuration file</li>
<li>Restart Apache</li>
<li>Setting Up <code>.htaccess</code></li>
</ul>

<p>First we need to activate <code>mod_rewrite</code>. It's available but not enabled with a clean <code>Apache 2</code> installation</p>

<p>You can use the following command  </p>

<pre><code>sudo a2enmod rewrite  
</code></pre>

<p>This will activate the module or alert you that the module is already enabled.</p>

<p>By default, <mark>Apache</mark> prohibits using an <code>.htaccess</code> file to apply <mark>rewrite rules</mark>, so first you need to allow changes to the file. Open the default <mark>Apache configuration file</mark> using <mark>nano</mark> or your favourite text editor.</p>

<pre><code>sudo nano /etc/apache2/sites-available/000-default.conf  
</code></pre>

<p>Inside that file, you will find a <code>&lt;VirtualHost *:80&gt;</code> block starting on the first line. Inside of that block, add the following new block so your configuration file looks like the following. Make sure that all blocks are properly indented.</p>

<pre><code>&lt;VirtualHost *:80&gt;  
    &lt;Directory /var/www/html&gt;
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    &lt;/Directory&gt;

&lt;/VirtualHost&gt;  
</code></pre>

<p>Now <mark>Save</mark> and close the file .To put these changes into effect, <code>restart Apache</code></p>

<pre><code>sudo systemctl restart apache2  
</code></pre>

<p><code>mod_rewrite</code> is now fully <mark>enabled</mark>. In the next step we will set up an <code>.htaccess</code> file in the root folder <code>/var/www/html</code> where our angular files are placed and we  we'll use it to define <mark>rewrite rules</mark> for redirects</p>

<pre><code> RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]  
RewriteCond %{REQUEST_FILENAME} -d  
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]  
</code></pre>

<p>Also since we need to increase  SEO points, i like to add  some more code to <mark>.htaccess</mark> to <code>enable compression</code> and <code>leverage browser Caching</code> </p>

<pre><code>RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]  
RewriteCond %{REQUEST_FILENAME} -d  
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]


# Enable Compression
&lt;IfModule mod_deflate.c&gt;  
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
&lt;/IfModule&gt;  
&lt;IfModule mod_gzip.c&gt;  
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
&lt;/IfModule&gt;

# Leverage Browser Caching
&lt;IfModule mod_expires.c&gt;  
  ExpiresActive On
  ExpiresByType image/jpg "access 1 year"
  ExpiresByType image/jpeg "access 1 year"
  ExpiresByType image/gif "access 1 year"
  ExpiresByType image/png "access 1 year"
  ExpiresByType text/css "access 1 month"
  ExpiresByType text/html "access 1 month"
  ExpiresByType application/pdf "access 1 month"
  ExpiresByType text/x-javascript "access 1 month"
  ExpiresByType application/x-shockwave-flash "access 1 month"
  ExpiresByType image/x-icon "access 1 year"
  ExpiresDefault "access 1 month"
&lt;/IfModule&gt;  
&lt;IfModule mod_headers.c&gt;  
  &lt;filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"&gt;
  Header set Cache-Control "max-age=2678400, public"
  &lt;/filesmatch&gt;
  &lt;filesmatch "\.(html|htm)$"&gt;
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  &lt;/filesmatch&gt;
  &lt;filesmatch "\.(pdf)$"&gt;
  Header set Cache-Control "max-age=86400, public"
  &lt;/filesmatch&gt;
  &lt;filesmatch "\.(js)$"&gt;
  Header set Cache-Control "max-age=2678400, private"
  &lt;/filesmatch&gt;
&lt;/IfModule&gt;  
</code></pre>

<p><br></p>

<p>Now if you refresh your app in browser the app will work fine </p>

<p><br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/11/angular6-page-refresh-404-not-found-error-solution.gif" alt="Angular 6+ deploy to Apache server by solving 404 Not found error on page refresh"></p>]]></content:encoded></item><item><title><![CDATA[AngularJs remove  # (hash) from url or setup Pretty URL]]></title><description><![CDATA[This article will help you to setup pretty url in AngularJs Apps or to remove # from url.]]></description><link>http://joeljoseph.net:80/angularjs-remove-hash-from-url/</link><guid isPermaLink="false">b6bc1a98-fe26-4d8c-8e62-31cad9c1d12f</guid><category><![CDATA[AngularJs]]></category><category><![CDATA[pretty-url]]></category><category><![CDATA[Singlepage App]]></category><category><![CDATA[Javascript]]></category><category><![CDATA[Apache]]></category><category><![CDATA[htaccess]]></category><category><![CDATA[enable compression]]></category><category><![CDATA[leverage browser Caching]]></category><category><![CDATA[$locationProvider]]></category><category><![CDATA[html5Mode]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Thu, 09 Aug 2018 16:06:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2018/08/postheader.png" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2018/08/postheader.png" alt="AngularJs remove  # (hash) from url or setup Pretty URL"><p>This article will help you to setup Pretty URL in AngularJs, that is to remove # from url.</p>

<p>AngularJS applications by default route with # in the url, the reason for the same is that # is an old browser shortcut which doesn't fire the request.This allows many JavaScript frameworks to build their own client side rerouting.</p>

<p>We need the # (hashtag) for non HTML5 browsers, otherwise they will just do an HTTP call to the server at the mentioned href.</p>

<p><br>  </p>

<h6>Url with # </h6>

<pre><code>http://example-domain.com/#/home  
</code></pre>

<h6>Url without # </h6>

<pre><code>http://example-domain.com/home  
</code></pre>

<p><br>  </p>

<h5> Getting Started </h5>

<p>For now let's hope you have already setup a new AngularJs project or has an existing AngularJs project.Here we are considering working with an existing AngularJs App. I have named my project as <mark>angular-one-sample</mark>.</p>

<p>The project was scaffolded using <a href="https://github.com/Swiip/generator-gulp-angular">Yeoman gulp-angular</a> generator , <a href="http://yeoman.io/">Yeoman</a> is scaffolding tool for modern web apps and can be used to generate basic app structure for your projects. </p>

<p><br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/08/project-setup-angularjs-yeoman.gif" alt="AngularJs remove  # (hash) from url or setup Pretty URL"></p>

<p>After generating the basic app using Yeoman  the project structure looks something like this <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/08/project-structure-angularjs-1.png" alt="AngularJs remove  # (hash) from url or setup Pretty URL"></p>

<p>if you want to run the same in local just  use the command  </p>

<pre><code>gulp serve --open  
</code></pre>

<p>The above command will start serving the  project at the url  </p>

<pre><code>http://localhost:3000/#/home  
</code></pre>

<p><br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/08/gulp-serve-angularjs.png" alt="AngularJs remove  # (hash) from url or setup Pretty URL"></p>

<p><br>  </p>

<h5> To remove # </h5>  

<p>To remove the # from URL we need to make sure  4  things mainly.</p>

<ul>
<li>Configure the <strong>$locationProvider</strong></li>
<li>Setting our <strong>base</strong> for relativelinks</li>
<li>Edit  your <mark>.htaccess</mark> file if you are using apache server</li>
<li>Remove # from the routing links through out the app (optional)</li>
</ul>

<p><br>  </p>

<h6> Configure $locationProvider</h6>  

<p>Angularjs <a href="https://docs.angularjs.org/guide/dev_guide.services.$location">$location</a> service parses the URL in the address bar and makes changes to your application and vice versa.
<br> <br>
We will use the <mark>$locationProvider</mark> module and set <mark>html5Mode</mark> to true.</p>

<p>Now  import the <strong>$locationProvider</strong> module to the router file <mark>index.route.js</mark> and add the following code to enable the <strong>html5Mode</strong></p>

<pre><code> // use the HTML5 History API
 $locationProvider.html5Mode(true);
</code></pre>

<p><strong>html5Mode</strong> is a standardized way to manipulate the browser history using a script. This lets Angularjs change the routing and URLs of our pages without refreshing the page.</p>

<p>After editing the router file it will look something like this <br>
<br> <br>
<strong>index.route.js</strong>  </p>

<pre><code>(function() {
  'use strict';

  angular
    .module('angularOneSample')
    .config(routerConfig);

  /** @ngInject */
  function routerConfig($stateProvider, $urlRouterProvider,$locationProvider) {
    $stateProvider
      .state('home', {
        url: '/home',
        templateUrl: 'app/main/main.html',
        controller: 'MainController',
        controllerAs: 'main'
      });


    // use the HTML5 History API
    $locationProvider.html5Mode(true)
    $urlRouterProvider.otherwise('/');
  }

})();
</code></pre>

<p><br>  </p>

<h6>Setting our Base</h6>  

<p>To link around your application using relative links, you will need to set a <code>&lt;base&gt;</code> in the <code>&lt;head&gt;</code> of your document. while setting base you will have to consider   where the projects resides in the server</p>

<p>if your project files is placed in the <code>/var/www/html</code>  folder (that is  project files copied from dist folder after <mark>gulp build</mark> to root folder of your server) or you are running on <mark>gulp serve</mark>  (while under development in local) then  your base will be</p>

<pre><code>&lt;base href="/"&gt;  
</code></pre>

<p>if your project files resides in some folder <mark>somefolder</mark>   then set base to</p>

<pre><code>&lt;base href="/somefolder/"&gt;  
</code></pre>

<p>In my case while developing (on <mark>gulp serve</mark>) in local i had to set base to</p>

<pre><code>&lt;base href="/"&gt;  
</code></pre>

<p><br> <br>
<strong>index.html</strong>  </p>

<pre><code>&lt;!doctype html&gt;  
&lt;html&gt;  
&lt;head&gt;  
    &lt;meta charset="utf-8"&gt;
    &lt;base href="/"&gt;
&lt;/head&gt;  
</code></pre>

<p>Now you can see that the app reloads  and # is removed from url</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/08/local-gulp-serve-hash-removed.png" alt="AngularJs remove  # (hash) from url or setup Pretty URL"></p>

<h6>Edit  your <mark>.htaccess</mark> file</h6>  

<p>Sometimes while While running on the <strong>Apache server</strong> Angulajs Apps seems to hit <code>404 Page Not found</code> error on page refresh.  To solve this issue we need to add the <mark>.htaccess</mark> file  with the following code to the <strong> project folder/root folder </strong> where project files are placed</p>

<pre><code> RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]  
RewriteCond %{REQUEST_FILENAME} -d  
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]  
</code></pre>

<p>Also since we are enabling <strong>pretty url</strong> to increase  SEO points, i like to add  some more code to <mark>.htaccess</mark> to <code>enable compression</code> and <code>leverage browser Caching</code> </p>

<pre><code>RewriteEngine on

# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]  
RewriteCond %{REQUEST_FILENAME} -d  
RewriteRule ^ - [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]


# Enable Compression
&lt;IfModule mod_deflate.c&gt;  
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
&lt;/IfModule&gt;  
&lt;IfModule mod_gzip.c&gt;  
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
&lt;/IfModule&gt;

# Leverage Browser Caching
&lt;IfModule mod_expires.c&gt;  
  ExpiresActive On
  ExpiresByType image/jpg "access 1 year"
  ExpiresByType image/jpeg "access 1 year"
  ExpiresByType image/gif "access 1 year"
  ExpiresByType image/png "access 1 year"
  ExpiresByType text/css "access 1 month"
  ExpiresByType text/html "access 1 month"
  ExpiresByType application/pdf "access 1 month"
  ExpiresByType text/x-javascript "access 1 month"
  ExpiresByType application/x-shockwave-flash "access 1 month"
  ExpiresByType image/x-icon "access 1 year"
  ExpiresDefault "access 1 month"
&lt;/IfModule&gt;  
&lt;IfModule mod_headers.c&gt;  
  &lt;filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"&gt;
  Header set Cache-Control "max-age=2678400, public"
  &lt;/filesmatch&gt;
  &lt;filesmatch "\.(html|htm)$"&gt;
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  &lt;/filesmatch&gt;
  &lt;filesmatch "\.(pdf)$"&gt;
  Header set Cache-Control "max-age=86400, public"
  &lt;/filesmatch&gt;
  &lt;filesmatch "\.(js)$"&gt;
  Header set Cache-Control "max-age=2678400, private"
  &lt;/filesmatch&gt;
&lt;/IfModule&gt;  
</code></pre>

<p><br>  </p>

<h6>Remove # from links used in the app</h6>  

<p>This step is optional, even if the # in navigation links were not removed, the links will work without any problem . These links automatically will be redirected to links without # (hash)</p>

<p><br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/08/hash-removed-url-1.gif" alt="AngularJs remove  # (hash) from url or setup Pretty URL"></p>]]></content:encoded></item><item><title><![CDATA[Angular 6 make  Header Sticky on Scroll]]></title><description><![CDATA[This article will help you to make header component sticky on scrolling on another component.]]></description><link>http://joeljoseph.net:80/angular-sticky-header-on-scroll/</link><guid isPermaLink="false">93eeabf5-85ae-4394-9fdf-547159114420</guid><category><![CDATA[Angular]]></category><category><![CDATA[Angular 6]]></category><category><![CDATA[Html]]></category><category><![CDATA[Components]]></category><category><![CDATA[add-class-on-scroll]]></category><category><![CDATA[css]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sat, 04 Aug 2018 15:45:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2018/08/dn469161-homepage_hero_backgrounds-1.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2018/08/dn469161-homepage_hero_backgrounds-1.jpg" alt="Angular 6 make  Header Sticky on Scroll"><p>This article will help you to make header component sticky on scrolling on another component.</p>

<p>Let's consider situation where you have an Angular 6 application with 2 components other than root component </p>

<ul>
<li>Header component</li>
<li>Home component</li>
</ul>

<p><br></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/08/fixed-header-angular-on-scroll.gif" alt="Angular 6 make  Header Sticky on Scroll"></p>

<p><br> <br>
In order to make the Header component sticky while  scrolling on Home Component what we need to do is add a new class (some class name) , here in my case it is <mark>sticky</mark></p>

<h6>Css class</h6>  

<pre><code>.sticky {
    background: #fff;
    box-shadow: 0 3px 12px 0 rgba(0,0,0,.08);
    position: fixed;
    top: 0;
    height: 120px;
    width: 100%;
}
</code></pre>

<p><br></p>

<p>First we need to give an <strong>id</strong> attribute to the header component so we can identify which element we to add the class <mark>sticky</mark> . Here i am giving it an id <mark>navbar</mark> <br>
<br>  </p>

<h6> header.component.html </h6>

<pre><code>&lt;header class="animated fadeInDown" id="navbar"&gt;  
 &lt;!-- other html code --&gt;
&lt;/header&gt;  
</code></pre>

<p>Now go to the Home Component and  write a function to handle the scroll event <br>
<br>  </p>

<h6> home.component.ts </h6>  

<pre><code>import { Component, OnInit, HostListener, Inject } from '@angular/core';  
import { trigger, state, transition, style, animate } from '@angular/animations';  
import { DOCUMENT } from '@angular/common';

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss'],
  animations:[ 
    trigger('fade',
    [ 
      state('void', style({ opacity : 0})),
      transition(':enter',[ animate(300)]),
      transition(':leave',[ animate(500)]),
    ]
)]
})
export class HomeComponent implements OnInit {


  constructor(@Inject(DOCUMENT) document) { }

  ngOnInit() {  }

  @HostListener('window:scroll', ['$event'])
  onWindowScroll(e) {
     if (window.pageYOffset &gt; 550) {
       let element = document.getElementById('navbar');
       element.classList.add('sticky');
     } else {
      let element = document.getElementById('navbar');
        element.classList.remove('sticky'); 
     }
  }


}
</code></pre>

<p><br></p>

<p>Next we need to add the scroll event  in the Home Component  to trigger the <mark>onWindowScroll</mark>  function on scroll event </p>

<p><br></p>

<h6> home.component.html </h6>

<pre><code>&lt;section class="web_homePage" (scroll)="onWindowScroll($event);"&gt;  
   &lt;!-- rest of the html code goes here --&gt;
&lt;/section&gt;  
</code></pre>

<p>Now you can see that a new class is added / removed  to the element with id <mark>navbar</mark>  on scrolling on the Home component</p>

<p><br></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/08/sticky-header-angular-on-scroll.gif" alt="Angular 6 make  Header Sticky on Scroll"></p>]]></content:encoded></item><item><title><![CDATA[AngularJs solve broken image  on failing to  load image from dynamic URL]]></title><description><![CDATA[This article will help you to deal with broken images in AngularJs apps when you load images from dynamic URL.]]></description><link>http://joeljoseph.net:80/angularjs-solve-broken-image-on-failing-to-load-image-from-url/</link><guid isPermaLink="false">ebee46d1-3e67-4824-867e-c85f868f0112</guid><category><![CDATA[AngularJs]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Html]]></category><category><![CDATA[broken-image]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sat, 04 Aug 2018 15:44:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2018/08/IC806114.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2018/08/IC806114.jpg" alt="AngularJs solve broken image  on failing to  load image from dynamic URL"><p>This article will help you to deal with broken images in AngularJs apps when you load images from dynamic URL.</p>

<p>If you have developed web application before , there must be situations where you had to deal with broken images , you must have searched for a solution in the Stack-overflow for the same.</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/08/broken-image.png" alt="AngularJs solve broken image  on failing to  load image from dynamic URL"></p>

<p>The most common solution you find will be some thing like the JavaScript code below which can be found in the following thread in <a href="https://stackoverflow.com/questions/92720/jquery-javascript-to-replace-broken-images">StackOverflow</a></p>

<pre><code>&lt;img src="image.png" onError="this.onerror=null;this.src='/images/default-image.png';" /&gt;
</code></pre>

<p>But this solution can only be used when you are loading images from the project   static URL. But in AngularJs  sometimes you may have to bind URL to some property or interpolate the same.</p>

<pre><code>&lt;img ng-src="{{url}}" onError="this.onerror=null;this.src='/images/default-image.png';" /&gt;
</code></pre>

<p><br>  </p>

<h5>Best Solution </h5>

<p>The best solution  to handle the same is to create a <mark>onError</mark>  <b>directive</b> so that you can reuse the same in multiple places</p>

<p><b>Javascript Code</b>  </p>

<pre><code>app.directive('onError', function() {  
  return {
    restrict:'A',
    link: function(scope, element, attr) {
      element.on('error', function() {
        element.attr('src', attr.onError);
      })
    }
  }
})
</code></pre>

<p><br>  </p>

<h6>Html code</h6>  

<p>In the html code you can use the angular directive to specify the default image. </p>

<pre><code>&lt;img ng-src="{{url}}" on-error="/images/default-image.png" /&gt;
</code></pre>

<p>You can see that the broken image is replaced with default image.</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/08/fixed-broken-image.png" alt="AngularJs solve broken image  on failing to  load image from dynamic URL"></p>]]></content:encoded></item><item><title><![CDATA[Is it Ok to use AngularJs (1.x) instead of Angular (2+)]]></title><description><![CDATA[This article will help you to choose between AngularJs (1.x version) or Angular (2+ version).]]></description><link>http://joeljoseph.net:80/is-it-ok-to-use-angularjs-instead-of-angular/</link><guid isPermaLink="false">f2fd7958-47df-4f24-9afe-962af3fbf332</guid><category><![CDATA[AngularJs]]></category><category><![CDATA[Angular]]></category><category><![CDATA[frontend framework]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[Single Page Apps]]></category><category><![CDATA[Angular 6]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Fri, 03 Aug 2018 18:10:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2018/08/dn469161-homepage_hero_backgrounds.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2018/08/dn469161-homepage_hero_backgrounds.jpg" alt="Is it Ok to use AngularJs (1.x) instead of Angular (2+)"><p>This article will help you to choose between AngularJs (1.x version) or Angular (2+ version).</p>

<p>If you have developed single page applications before, you  must had  situations where you had to choose between <b>AngularJs</b> and <b>Angular</b> . You must have googled to find the solution , or performed a search in Stack-overflow.</p>

<p>Yes this is 2018 you may find it difficult to choose between the two. </p>

<p>I have been a AngularJs developer since 2014 and  later upgraded to Angular (2+) and is currently working on Angular version 6 projects. I can give you few points regarding the same.</p>

<h5> My Answer </h5>

<p>It depends on the <mark>type of project</mark> and <mark>time frame</mark> and the <mark>availability of resources</mark> you have.</p>

<h6> Let's talk </h6>

<p>The complete explanation  including the technical aspects is out of scope of this article , but i can give you few basic points.</p>

<p><br>  </p>

<h6>Why and when should you consider using AngularJs ?</h6>

<ul>
<li><p>If you already have AngularJs Development Team at hand</p></li>
<li><p>If the project is a short term project and requires fast development process no time to invest on new resources</p></li>
<li><p>If your development team is small and you need to use existing javascript team for the project</p></li>
<li><p>Angular 2+ is some what  diffrent framework and will require time for upgrading existing AngularJS developers to the same. </p></li>
<li><p>Angular (currently version 6, version seven coming next month ) updates every 6 months. Some developers find it painful to update the version of the app every 6 months if you are working on a project with huge development timeframe 
[ <mark>I disagree with this point though</mark> ]</p></li>
<li><p>AngularJs has huge Community Support .It opens a large scale of options both to developers and clients. Developers may easily find various info and solutions</p></li>
</ul>

<p><br></p>

<h6> Why AngularJs (1.x) still exist ? </h6>  

<p>This is 2018 and even after the  release of <b>Angular 6</b> the <b>AngularJs</b> currently at version 1.7 is still live and kicking. Looking into the details we could see the reason behind the same as following.</p>

<ul>
<li><p>AngularJs was a widely used frontend framework to make Single Page applications and many of the big and small projects rely on this framework. Even if Google were to stop their support, somebody would fork Angular 1 and continue to maintain it as an independent framework</p></li>
<li><p>AngularJS developers will be more widely available than those who updated to the latest version of Angular </p></li>
<li><p>Cost of the resources is another factor as companies can still rely on resources who work in older framework</p></li>
<li><p>AngularJs is a stable  frontend framework and and has huge plugins base and other support packages</p></li>
<li><p>From July 1st 2018, AngularJs has entered into  Long Term Support period</p></li>
<li><p>The web's scaffolding tool like Yeoman provide generators for scaffolding AngularJs  projects , giving it developer tools support similar to Angular cli</p></li>
<li><p>In the case of performance AngularJs lags behind the latest version of Angular ( version 6 ) but still it gives a decent performance</p></li>
<li><p>Finally the last  reason, even though upgrading your existing project from AngularJs to Angular is possible it takes lot of work. it will have to undergo many changes  and is not  worth the time , money, effort and number of resources spend on the same  </p></li>
</ul>

<p><br></p>

<h6>When Should you consider using Angular(2+) ? </h6>

<ul>
<li><p>using the latest development stack is one of the greatest advantage over the competion</p></li>
<li><p>If you are working on longterm project with a huge team of developers</p></li>
<li><p>If the project is huge and consist of different modules and need continuous support </p></li>
<li><p>Angular has great  list of development  toolset to make the development much more easy</p></li>
<li><p>Performance wise Angular outruns AngularJs</p></li>
<li><p>If you are in process of developing your on Angular Team</p></li>
<li><p>Angular is being improved and may get much better in the future updates in all aspects</p></li>
<li><p>Software Industry is currently moving  to  Angular 2+ and in the future google may stop support for the AngularJS</p></li>
</ul>

<p><br></p>

<p>There are many more reasons including technical aspects, tools, performance and SEO but i would like to keep this article to be minimal.</p>]]></content:encoded></item><item><title><![CDATA[Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK]]></title><description><![CDATA[This article will help you to setup the Google Authentication  in a Windows 10 Universal Platform App using Azure Mobile App SDK.]]></description><link>http://joeljoseph.net:80/google-authentication-in-existing-universal-windows-platform-uwp-app-using-azure-mobile-app-sdk/</link><guid isPermaLink="false">f659c878-16c1-409c-9f51-f2bcfce07fa5</guid><category><![CDATA[C#]]></category><category><![CDATA[MVVM]]></category><category><![CDATA[UWP]]></category><category><![CDATA[MVVM Light]]></category><category><![CDATA[Windows 10]]></category><category><![CDATA[Universal Windows Platform]]></category><category><![CDATA[Google]]></category><category><![CDATA[Authentication]]></category><category><![CDATA[Azure]]></category><category><![CDATA[Azure Mobile App]]></category><category><![CDATA[Google Login For UWP]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sun, 29 May 2016 00:33:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2018/03/postheader-1.png" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2018/03/postheader-1.png" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"><p>This article will help you to setup the Google Authentication  in a Windows 10 Universal Platform App using Azure Mobile App SDK.</p>

<h5>Getting Started</h5>  

<p>For now let's hope you have already setup a blank project for Universal Windows Platform as we are considering connecting an existing App with Azure. I have named my solution as <mark>Win10GoogleAuthenticationDemo</mark>.</p>

<p>The App has a single page <mark>LoginPage.xaml</mark></p>

<h6>LoginPage.xaml</h6>  

<p><img src="http://joeljoseph.net:80/content/images/2018/03/LoginPage.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK">
<br> <br>
The Xaml code for the page is:</p>

<pre><code>&lt;Page  
    x:Class="Win10GoogleAuthenticationDemo.LoginPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10GoogleAuthenticationDemo"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"&gt;
    &lt;Page.Resources&gt;
        &lt;Style x:Key="GoogleSignUpButtonStyle" TargetType="Button"&gt;
            &lt;Setter Property="Background" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}"/&gt;
            &lt;Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}"/&gt;
            &lt;Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundTransparentBrush}"/&gt;
            &lt;Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/&gt;
            &lt;Setter Property="Padding" Value="8,4,8,4"/&gt;
            &lt;Setter Property="HorizontalAlignment" Value="Left"/&gt;
            &lt;Setter Property="VerticalAlignment" Value="Center"/&gt;
            &lt;Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/&gt;
            &lt;Setter Property="FontWeight" Value="Normal"/&gt;
            &lt;Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/&gt;
            &lt;Setter Property="UseSystemFocusVisuals" Value="True"/&gt;
            &lt;Setter Property="Template"&gt;
                &lt;Setter.Value&gt;
                    &lt;ControlTemplate TargetType="Button"&gt;
                        &lt;Grid x:Name="RootGrid" Background="{TemplateBinding Background}"&gt;
                            &lt;VisualStateManager.VisualStateGroups&gt;
                                &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                    &lt;VisualState x:Name="Normal"&gt;
                                        &lt;Storyboard&gt;
                                            &lt;PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/&gt;
                                        &lt;/Storyboard&gt;
                                    &lt;/VisualState&gt;
                                    &lt;VisualState x:Name="PointerOver"&gt;
                                        &lt;Storyboard&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumLowBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseHighBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/&gt;
                                        &lt;/Storyboard&gt;
                                    &lt;/VisualState&gt;
                                    &lt;VisualState x:Name="Pressed"&gt;
                                        &lt;VisualState.Setters&gt;
                                            &lt;Setter Target="ContentPresenter.(ContentPresenter.Background)"&gt;
                                                &lt;Setter.Value&gt;
                                                    &lt;SolidColorBrush Color="#FFC73030"/&gt;
                                                &lt;/Setter.Value&gt;
                                            &lt;/Setter&gt;
                                        &lt;/VisualState.Setters&gt;
                                        &lt;Storyboard&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0"&gt;
                                                    &lt;DiscreteObjectKeyFrame.Value&gt;
                                                        &lt;SolidColorBrush Color="{StaticResource SystemBaseHighColor}"/&gt;
                                                    &lt;/DiscreteObjectKeyFrame.Value&gt;
                                                &lt;/DiscreteObjectKeyFrame&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/&gt;
                                        &lt;/Storyboard&gt;
                                    &lt;/VisualState&gt;
                                    &lt;VisualState x:Name="Disabled"&gt;
                                        &lt;Storyboard&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                            &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter"&gt;
                                                &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledTransparentBrush}"/&gt;
                                            &lt;/ObjectAnimationUsingKeyFrames&gt;
                                        &lt;/Storyboard&gt;
                                    &lt;/VisualState&gt;
                                &lt;/VisualStateGroup&gt;
                            &lt;/VisualStateManager.VisualStateGroups&gt;
                            &lt;ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/&gt;
                        &lt;/Grid&gt;
                    &lt;/ControlTemplate&gt;
                &lt;/Setter.Value&gt;
            &lt;/Setter&gt;
        &lt;/Style&gt;
    &lt;/Page.Resources&gt;
    &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
        &lt;Button x:Name="GoogleSignUp"  Background="#FFDB4C3F" BorderThickness="0" Foreground="White" Height="30"  Margin="0,10,0,15" Width="240"  HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource GoogleSignUpButtonStyle}" Click="logIn" &gt;
            &lt;StackPanel  Orientation="Horizontal"&gt;
                &lt;Viewbox Width="38" Height="20" HorizontalAlignment="Left" Margin="0"&gt;
                    &lt;Canvas Width="27" Height="27"&gt;
                        &lt;Path Data="M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z" Fill="White" /&gt;
                    &lt;/Canvas&gt;
                &lt;/Viewbox&gt;
                &lt;TextBlock Text="Log in With Google" Foreground="White" FontSize="14" Width="150"/&gt;
            &lt;/StackPanel&gt;
        &lt;/Button&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre>

<h6>LoginPage.xaml.cs</h6>  

<p><br> <br>
The  code for the <mark>LoginPage.xaml.cs</mark> :</p>

<pre><code>using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Linq;  
using System.Runtime.InteropServices.WindowsRuntime;  
using Windows.Foundation;  
using Windows.Foundation.Collections;  
using Windows.UI.Xaml;  
using Windows.UI.Xaml.Controls;  
using Windows.UI.Xaml.Controls.Primitives;  
using Windows.UI.Xaml.Data;  
using Windows.UI.Xaml.Input;  
using Windows.UI.Xaml.Media;  
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace Win10GoogleAuthenticationDemo  
{
    /// &lt;summary&gt;
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// &lt;/summary&gt;
    public sealed partial class LoginPage : Page
    {
        public LoginPage()
        {
            this.InitializeComponent();
        }

        private void logIn(object sender, RoutedEventArgs e)
        {

        }
    }
}
</code></pre>

<p>Now that the App is ready  you will need a Azure Mobile App to be created for your App</p>

<h6>Create a New Azure Mobile App</h6>

<p>You will need to create a <mark>Azure Mobile App</mark> in your  Azure portal. For this login to your Azure Portal and create a new Azure mobile App. Let's name it <mark>GoogleLoginDemo</mark>.</p>

<p>First in the Azure Portal <mark>Click</mark> on  <b>New </b> on the blade that pop's up choose  <b>Web + Mobile</b> which will then opens another blade with a list of <mark>Featured Apps</mark>. From the list select <b> Mobile App</b> . This is the starting point to configure your Azure Mobile App Backend.</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/AzurePortal.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>Now name the <mark>Mobile App Service</mark> and  choose a <mark>Subscription</mark> and <mark>Resource Group</mark> and click <b>Create</b></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/NametheApp.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>After this you new Mobile App Will be added to your portal all up and running with a new blade will be opened with App details.The <b>Url</b> of the service is also provided in the blade</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/AppDetails.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>Visit the Url of your Mobile App and make sure the service is running . Here is the url of my app : <a href="http://googlelogindemo.azurewebsites.net">http://googlelogindemo.azurewebsites.net</a> </p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/applink-1.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<h6>Register your application with Google</h6>  

<p>To complete the procedure in this topic, you must have a Google account that has a verified email address. To create a new Google account, go to <a href="http://go.microsoft.com/fwlink/p/?LinkId=268302">accounts.google.com</a>.</p>

<p>Log on to the <a href="https://portal.azure.com/">Azure portal</a>, and navigate to your application. Copy your URL. You will use this to configure your <mark>Google app</mark></p>

<p>Navigate to the <a href="http://go.microsoft.com/fwlink/p/?LinkId=268303">Google apis</a> website, sign-in with your Google account credentials, click <b>Create Project</b>, provide a <mark>Project name</mark> lets name it <mark>LoginDemoAzure</mark>, then click <b>Create</b></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/googleapp-1.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>Under <mark>Social APIs</mark> click <mark>Google+ API</mark> and then <b>Enable</b>.</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/enable.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>In the left navigation, <b>Credentials > OAuth consent</b> screen, then select your <mark>Email address</mark>, enter a <mark>Product Name</mark>, and click <b>Save</b>.</p>

<p>In the <b>Credentials</b> tab, click <b>Create</b> <b>credentials > OAuth client ID</b>, then select <b>Web application</b></p>

<p><b>Paste</b> the <mark>App Service URL</mark> you copied earlier into <b>Authorized JavaScript Origins</b>, then paste your <b>redirect URI</b> into <b>Authorized Redirect URI</b>. The redirect <b>URI</b> is the <b>URL</b> of your application  appended with the path, <mark>/.auth/login/google/callback</mark>. For example my Url is , <a href="https://googlelogindemo.azurewebsites.net/.auth/login/google/callback">https://googlelogindemo.azurewebsites.net/.auth/login/google/callback</a>. </p>

<p>Make sure that you are using the <b>HTTPS</b> scheme. Then click <b>Create</b>.</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/credinals.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>Now On the next screen, make a note of the values of the <b>client ID</b> and <b>client secret</b>. <br>
<br>  </p>

<h6>Add Google information to your Azure App</h6>

<p>Back in the <mark>Azure portal</mark>, navigate to your application. Click <b>Settings</b>, and then <b>Authentication / Authorization</b>.</p>

<p>If the <b>Authentication / Authorization</b> feature is not enabled, <mark>turn the switch to On</mark>.</p>

<p>Click <mark>Google</mark>. Paste in the <b>App ID</b> and <b>App Secret</b> values which you obtained previously, and optionally <b>enable</b> any scopes your application requires. Then click <b>OK</b>.</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/Authedicatin-Enable-Azure.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/adddetailstoazuregoogletab.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>

<p>By this much you are almost ready all that left for you is to is to work with the UWP blank App that we created.</p>

<p><br>  </p>

<h5>Add Authentication to  UWP App</h5> 

<p>You will now have to modify the <mark>Win10GoogleAuthenticationDemo</mark> app that we created in the first step.</p>

<h6>Install</h6>  

<p>Install the <b>Azure Mobile App SDk</b> with <b>Nuget</b></p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/nuget.JPG" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK">
<br> <br>
Make sure that you install correct library <b>Microsoft.Azure.Mobile.Client</b></p>

<p>Now you can connect the UWP App with the Azure Mobile App Service by adding the following  code to <b>App.xaml.cs</b></p>

<p>First add the dependency for MobileServices</p>

<pre><code>using Microsoft.WindowsAzure.MobileServices;  
</code></pre>

<p>Now add the following code inside sealed partial class App.</p>

<pre><code>// Connect to azure Mobile App Service   
        public static MobileServiceClient MobileService = new MobileServiceClient("https://googlelogindemo.azurewebsites.net/");
</code></pre>

<p>Now Modify the <mark>LoginPage.xaml.cs</mark>  to call the Authentication for google ., you will have to add following code to <mark>LoginPage.xaml.cs</mark> </p>

<pre><code> // Define a member variable for storing the signed-in user. 
private MobileServiceUser user;  
private async System.Threading.Tasks.Task&lt;bool&gt; AuthenticateAsync()  
{
    string message;
    bool success = false;

    // This sample uses the Google provider.
    var provider = MobileServiceAuthenticationProvider.Google;

    // Use the PasswordVault to securely store and access credentials.
    PasswordVault vault = new PasswordVault();
    PasswordCredential credential = null;

    try
    {
        // Try to get an existing credential from the vault.
        credential = vault.FindAllByResource(provider.ToString()).FirstOrDefault();
    }
    catch (Exception)
    {
        // When there is no matching resource an error occurs, which we ignore.
    }

    if (credential != null)
    {
        // Create a user from the stored credentials.
        user = new MobileServiceUser(credential.UserName);
        credential.RetrievePassword();
        user.MobileServiceAuthenticationToken = credential.Password;

        // Set the user from the stored credentials.
        App.MobileService.CurrentUser = user;

        // Consider adding a check to determine if the token is 
        // expired, as shown in this post: http://aka.ms/jww5vp.

        success = true;
        message = string.Format("Cached credentials for user - {0}", user.UserId);
    }
    else
    {
        try
        {
            // Login with the identity provider.
            user = await App.MobileService
                .LoginAsync(provider);

            // Create and store the user credentials.
            credential = new PasswordCredential(provider.ToString(),
                user.UserId, user.MobileServiceAuthenticationToken);
            vault.Add(credential);

            success = true;
            message = string.Format("You are now logged in - {0}", user.UserId);
        }
        catch (MobileServiceInvalidOperationException)
        {
            message = "You must log in. Login Required";
        }
    }

    var dialog = new MessageDialog(message);
    dialog.Commands.Add(new UICommand("OK"));
    await dialog.ShowAsync();

    return success;
}
</code></pre>

<p>In the AuthenticateAsync method, the app tries to use credentials stored in the PasswordVault to access the service. A regular sign-in is also performed when there is no stored credential.</p>

<p>Now if you call the <b>AuthenticateAsync</b> method in the login button Click function</p>

<p>After all the changes the <mark>LoginPage.xaml.cs</mark> will have the following code.</p>

<pre><code>using Microsoft.WindowsAzure.MobileServices;  
using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Linq;  
using System.Runtime.InteropServices.WindowsRuntime;  
using Windows.Foundation;  
using Windows.Foundation.Collections;  
using Windows.Security.Credentials;  
using Windows.UI.Popups;  
using Windows.UI.Xaml;  
using Windows.UI.Xaml.Controls;  
using Windows.UI.Xaml.Controls.Primitives;  
using Windows.UI.Xaml.Data;  
using Windows.UI.Xaml.Input;  
using Windows.UI.Xaml.Media;  
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace Win10GoogleAuthenticationDemo  
{
    /// &lt;summary&gt;
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// &lt;/summary&gt;
    public sealed partial class LoginPage : Page
    {
        // Define a member variable for storing the signed-in user. 
        private MobileServiceUser user;

        public LoginPage()
        {
            this.InitializeComponent();
        }

        private async System.Threading.Tasks.Task&lt;bool&gt; AuthenticateAsync()
        {
            string message;
            bool success = false;

            // This sample uses the Facebook provider.
            var provider = MobileServiceAuthenticationProvider.Google;

            // Use the PasswordVault to securely store and access credentials.
            PasswordVault vault = new PasswordVault();
            PasswordCredential credential = null;

            try
            {
                // Try to get an existing credential from the vault.
                credential = vault.FindAllByResource(provider.ToString()).FirstOrDefault();
            }
            catch (Exception)
            {
                // When there is no matching resource an error occurs, which we ignore.
            }

            if (credential != null)
            {
                // Create a user from the stored credentials.
                user = new MobileServiceUser(credential.UserName);
                credential.RetrievePassword();
                user.MobileServiceAuthenticationToken = credential.Password;

                // Set the user from the stored credentials.
                App.MobileService.CurrentUser = user;

                // Consider adding a check to determine if the token is 
                // expired, as shown in this post: http://aka.ms/jww5vp.

                success = true;
                message = string.Format("Cached credentials for user - {0}", user.UserId);
            }
            else
            {
                try
                {
                    // Login with the identity provider.
                    user = await App.MobileService
                        .LoginAsync(provider);

                    // Create and store the user credentials.
                    credential = new PasswordCredential(provider.ToString(),
                        user.UserId, user.MobileServiceAuthenticationToken);
                    vault.Add(credential);

                    success = true;
                    message = string.Format("You are now logged in - {0}", user.UserId);
                }
                catch (MobileServiceInvalidOperationException)
                {
                    message = "You must log in. Login Required";
                }
            }

            var dialog = new MessageDialog(message);
            dialog.Commands.Add(new UICommand("OK"));
            await dialog.ShowAsync();

            return success;
        }

        private  async void logIn(object sender, RoutedEventArgs e)
        {
            // Login the user 
            if (await AuthenticateAsync())
            {
              // do something 
            }


        }





    }
}
</code></pre>

<p>Now if you run the Project the Google Authentication will work , look at the screen shot below to see the result.</p>

<p><img src="http://joeljoseph.net:80/content/images/2016/05/result.gif" alt="Google Authentication in Existing  Universal Windows Platform(UWP) App Using Azure Mobile App SDK"></p>]]></content:encoded></item><item><title><![CDATA[Customizing  Title Bar and Status Bar in Universal Windows Platform (UWP)]]></title><description><![CDATA[This article will help you to customize the Status Bar and Title Bar in a Windows 10 Universal Platform App.]]></description><link>http://joeljoseph.net:80/customizing-title-bar-and-status-bar-in-universal-windows-platform-uwp/</link><guid isPermaLink="false">ebfe94de-22c6-4f3f-8b04-b9a20ada24f5</guid><category><![CDATA[C#]]></category><category><![CDATA[UWP]]></category><category><![CDATA[Universal Windows App]]></category><category><![CDATA[Windows 10]]></category><category><![CDATA[Title Bar UWP]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sun, 17 Apr 2016 10:31:36 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2016/04/IC806114.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2016/04/IC806114.jpg" alt="Customizing  Title Bar and Status Bar in Universal Windows Platform (UWP)"><p>This article will help you to customize  the  Status Bar  and Title Bar in a Windows 10 Universal Platform App.</p>

<p>If you have been developing Apps for Windows 10, there are instances where you will need to  customize the Title Bar or Status Bar  like changing the color or adding back button.let's  see how this can be done.</p>

<h5>Gettig Started</h5>  

<p>For now let's hope you have already setup a blank project for Universal Windows Platform . I have named my solution as <mark>Win10CustomizingTitleBarDemo</mark>.</p>

<p>After the setup i have removed  the Frame Counter in the App, not that important i just don't need it in this scenario. Also there is <mark>MainPage.xaml</mark> page which is generated with the project Solution.</p>

<h6>MainPage.xaml</h6>  

<p><img src="http://joeljoseph.net:80/content/images/2018/03/MainPage.JPG" alt="Customizing  Title Bar and Status Bar in Universal Windows Platform (UWP)"></p>

<p><br> <br>
The XAML code for the page is :  </p>

<pre><code>&lt;Page  
    x:Class="Win10CustomizingTitleBarDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10CustomizingTitleBarDemo"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"&gt;

    &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;

    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre>

<p><br></p>

<p>The <mark>MainPage.xamal.cs</mark> has the following code:</p>

<pre><code>using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Linq;  
using System.Runtime.InteropServices.WindowsRuntime;  
using Windows.Foundation;  
using Windows.Foundation.Collections;  
using Windows.UI.Xaml;  
using Windows.UI.Xaml.Controls;  
using Windows.UI.Xaml.Controls.Primitives;  
using Windows.UI.Xaml.Data;  
using Windows.UI.Xaml.Input;  
using Windows.UI.Xaml.Media;  
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&amp;clcid=0x409

namespace Win10CustomizingTitleBarDemo  
{
    /// &lt;summary&gt;
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// &lt;/summary&gt;
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }
    }
}
</code></pre>

<p><br> <br>
The <mark>App.xaml.cs</mark> of the app look something like this:  </p>

<pre><code>using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Linq;  
using System.Runtime.InteropServices.WindowsRuntime;  
using Windows.ApplicationModel;  
using Windows.ApplicationModel.Activation;  
using Windows.Foundation;  
using Windows.Foundation.Collections;  
using Windows.UI.Xaml;  
using Windows.UI.Xaml.Controls;  
using Windows.UI.Xaml.Controls.Primitives;  
using Windows.UI.Xaml.Data;  
using Windows.UI.Xaml.Input;  
using Windows.UI.Xaml.Media;  
using Windows.UI.Xaml.Navigation;

namespace Win10CustomizingTitleBarDemo  
{
    /// &lt;summary&gt;
    /// Provides application-specific behavior to supplement the default Application class.
    /// &lt;/summary&gt;
    sealed partial class App : Application
    {
        /// &lt;summary&gt;
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// &lt;/summary&gt;
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }

        /// &lt;summary&gt;
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;Details about the launch request and process.&lt;/param&gt;
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {



            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }

        /// &lt;summary&gt;
        /// Invoked when Navigation to a certain page fails
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The Frame which failed navigation&lt;/param&gt;
        /// &lt;param name="e"&gt;Details about the navigation failure&lt;/param&gt;
        void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
        }

        /// &lt;summary&gt;
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source of the suspend request.&lt;/param&gt;
        /// &lt;param name="e"&gt;Details about the suspend request.&lt;/param&gt;
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            deferral.Complete();
        }
    }
}
</code></pre>

<p><br>  </p>

<h6>Change Title Bar Color </h6>

<p>Want to play around with the Title Bar of your app, you can easily do that. There are set of APIs that can help you to deal with playing around Title Bar. Instead of having default color of title bar, you can apply your own colors. Not only with colors, you can even customize the overall appearance of the Title bar.This is often useful when you want to match a color theme with your overall app along with the title bar.</p>

<p>If you Wish to maintain the color of Title bar through out the app then you can write the following code  inside the <mark>OnLaunched</mark> in the <mark>App.xaml.cs</mark> or if you wish to change the color for each page  then you can write the code inside the Code Behind for example <mark>MapinPage.xaml.cs</mark> inside the construct after the  call to InitializeComponent method.</p>

<p>I chose to maintain the color through out the app so code is placed inside OnLaunced method in  the App.xaml.cs:</p>

<pre><code> if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
            {
                var titleBar = ApplicationView.GetForCurrentView().TitleBar;
                if (titleBar != null)
                {
                    titleBar.ButtonBackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
                    titleBar.ButtonForegroundColor = Colors.White;
                    titleBar.BackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
                    titleBar.ForegroundColor = Colors.White;
                }
            }
</code></pre>

<p><br> <br>
You also have to add the dependency to App.xaml.cs:</p>

<pre><code>using Windows.Foundation.Metadata;  
using Windows.UI;  
using Windows.UI.ViewManagement;  
</code></pre>

<p>The code for  function  <mark>GetSolidColorBrush</mark>  </p>

<pre><code> //Function to convert Hex to Color
        public SolidColorBrush GetSolidColorBrush(string hex)
        {
            hex = hex.Replace("#", string.Empty);
            byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
            byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
            byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
            byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
            SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b));
            return myBrush;
        }
</code></pre>

<p>Also you can see that i have  used a custom function called <mark>GetSolidColorBrush</mark> to convert hex to colors. For more details on converting  Hex to Color in C#  read my other article <a href="http://www.joeljoseph.net/converting-hex-to-color-in-universal-windows-platform-uwp/">Converting Hex to Color in C# for Universal Windows Platform</a></p>

<p>After all the above steps the <mark>App.xaml.cs</mark> code will have the following code :</p>

<pre><code>using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Linq;  
using System.Runtime.InteropServices.WindowsRuntime;  
using Windows.ApplicationModel;  
using Windows.ApplicationModel.Activation;  
using Windows.Foundation;  
using Windows.Foundation.Collections;  
using Windows.Foundation.Metadata;  
using Windows.UI;  
using Windows.UI.ViewManagement;  
using Windows.UI.Xaml;  
using Windows.UI.Xaml.Controls;  
using Windows.UI.Xaml.Controls.Primitives;  
using Windows.UI.Xaml.Data;  
using Windows.UI.Xaml.Input;  
using Windows.UI.Xaml.Media;  
using Windows.UI.Xaml.Navigation;

namespace Win10CustomizingTitleBarDemo  
{
    /// &lt;summary&gt;
    /// Provides application-specific behavior to supplement the default Application class.
    /// &lt;/summary&gt;
    sealed partial class App : Application
    {
        /// &lt;summary&gt;
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// &lt;/summary&gt;
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }

        //Function to convert Hex to Color
        public SolidColorBrush GetSolidColorBrush(string hex)
        {
            hex = hex.Replace("#", string.Empty);
            byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
            byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
            byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
            byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
            SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b));
            return myBrush;
        }

        /// &lt;summary&gt;
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;Details about the launch request and process.&lt;/param&gt;
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
            {
                var titleBar = ApplicationView.GetForCurrentView().TitleBar;
                if (titleBar != null)
                {
                    titleBar.ButtonBackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
                    titleBar.ButtonForegroundColor = Colors.White;
                    titleBar.BackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
                    titleBar.ForegroundColor = Colors.White;
                }
            }


            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }

        /// &lt;summary&gt;
        /// Invoked when Navigation to a certain page fails
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The Frame which failed navigation&lt;/param&gt;
        /// &lt;param name="e"&gt;Details about the navigation failure&lt;/param&gt;
        void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
        }

        /// &lt;summary&gt;
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source of the suspend request.&lt;/param&gt;
        /// &lt;param name="e"&gt;Details about the suspend request.&lt;/param&gt;
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            deferral.Complete();
        }
    }
}
</code></pre>

<p>Now if you run the App you can find the color on your Title bar :</p>

<p><img src="http://joeljoseph.net:80/content/images/2018/03/TitleBarColor.JPG" alt="Customizing  Title Bar and Status Bar in Universal Windows Platform (UWP)"></p>

<p>In the Windows Mobile the scenario is different you have Status bar instead of the Title bar you will  have to use the following code  if you want to play with it.  Also remember that before to use any specific platform API you need to add a reference to the correspondent Extension. So you will have to add  reference to <mark>Windows Mobile Extensions for the UWP</mark>.</p>

<p>After this just use the following code to customize the status bar:</p>

<pre><code>//Mobile customization
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))  
{

    var statusBar = StatusBar.GetForCurrentView();
    if (statusBar != null)
    {
        statusBar.BackgroundOpacity = 1;
        statusBar.BackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
        statusBar.ForegroundColor = Colors.White;
    }
}
</code></pre>

<p><br>  </p>

<h6>Enable back button in the app title bar Windows 10 UWP</h6>

<p>In Windows 10 UWP the back button is disabled by default. If you need back button in the application title bar you need to enable it.</p>

<p>To enable the back button, first you need to  get the current view and enable the back button for this  you can use following code:  </p>

<pre><code>var view = SystemNavigationManager.GetForCurrentView();  
view.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;  
</code></pre>

<p><br> <br>
You will also have to create  an event handler to handle the back button click</p>

<p><code>view.BackRequested += BackRequested;</code></p>

<p>Add the following method to handle the back button click.  </p>

<pre><code>private void View_BackRequested(object sender, BackRequestedEventArgs e)  
        {
            // Do some thing
        }
</code></pre>

<p>After all the above steps the <mark>App.xaml.cs</mark>  will have the following code :  </p>

<pre><code>using System;  
using System.Collections.Generic;  
using System.IO;  
using System.Linq;  
using System.Runtime.InteropServices.WindowsRuntime;  
using Windows.ApplicationModel;  
using Windows.ApplicationModel.Activation;  
using Windows.Foundation;  
using Windows.Foundation.Collections;  
using Windows.Foundation.Metadata;  
using Windows.UI;  
using Windows.UI.Core;  
using Windows.UI.ViewManagement;  
using Windows.UI.Xaml;  
using Windows.UI.Xaml.Controls;  
using Windows.UI.Xaml.Controls.Primitives;  
using Windows.UI.Xaml.Data;  
using Windows.UI.Xaml.Input;  
using Windows.UI.Xaml.Media;  
using Windows.UI.Xaml.Navigation;

namespace Win10CustomizingTitleBarDemo  
{
    /// &lt;summary&gt;
    /// Provides application-specific behavior to supplement the default Application class.
    /// &lt;/summary&gt;
    sealed partial class App : Application
    {
        /// &lt;summary&gt;
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// &lt;/summary&gt;
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }

        //Function to convert Hex to Color
        public SolidColorBrush GetSolidColorBrush(string hex)
        {
            hex = hex.Replace("#", string.Empty);
            byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
            byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
            byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
            byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
            SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b));
            return myBrush;
        }

        /// &lt;summary&gt;
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// &lt;/summary&gt;
        /// &lt;param name="e"&gt;Details about the launch request and process.&lt;/param&gt;
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            var view = SystemNavigationManager.GetForCurrentView();
            view.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            view.BackRequested += View_BackRequested;
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
            {
                var titleBar = ApplicationView.GetForCurrentView().TitleBar;
                if (titleBar != null)
                {
                    titleBar.ButtonBackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
                    titleBar.ButtonForegroundColor = Colors.White;
                    titleBar.BackgroundColor = GetSolidColorBrush("#FFCD3927").Color;
                    titleBar.ForegroundColor = Colors.White;
                }
            }


            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }

        private void View_BackRequested(object sender, BackRequestedEventArgs e)
        {
            // do some thing
        }

        /// &lt;summary&gt;
        /// Invoked when Navigation to a certain page fails
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The Frame which failed navigation&lt;/param&gt;
        /// &lt;param name="e"&gt;Details about the navigation failure&lt;/param&gt;
        void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
        }

        /// &lt;summary&gt;
        /// Invoked when application execution is being suspended.  Application state is saved
        /// without knowing whether the application will be terminated or resumed with the contents
        /// of memory still intact.
        /// &lt;/summary&gt;
        /// &lt;param name="sender"&gt;The source of the suspend request.&lt;/param&gt;
        /// &lt;param name="e"&gt;Details about the suspend request.&lt;/param&gt;
        private void OnSuspending(object sender, SuspendingEventArgs e)
        {
            var deferral = e.SuspendingOperation.GetDeferral();
            //TODO: Save application state and stop any background activity
            deferral.Complete();
        }
    }
}
</code></pre>

<p><br></p>

<p>Now if you run the app you can you can see that the back button appeared in the Title Bar of the App : <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/Backbutton.JPG" alt="Customizing  Title Bar and Status Bar in Universal Windows Platform (UWP)"></p>]]></content:encoded></item><item><title><![CDATA[Navigation Between Pages Using MVVM Light in Universal Windows Platform(UWP)]]></title><description><![CDATA[<p>This article will help you to setup the basic Navigation with MVVM pattern in a Windows 10 Universal Platform App using MVVM Light Toolkit from Galasoft.</p>

<p>A complete explanation on how to  setup your  first Windows 10 Universal Windows Platform using MVVM Light can be found in this article: <a href="http://www.joeljoseph.net/using-mvvm-light-with-universal-windows-app-for-windows-10/">Using</a></p>]]></description><link>http://joeljoseph.net:80/navigation-between-pages-using-mvvm-light-in-universal-windows-platform-uwp/</link><guid isPermaLink="false">33721cca-a308-4e3e-9832-164e6487094b</guid><category><![CDATA[C#]]></category><category><![CDATA[MVVM]]></category><category><![CDATA[UWP]]></category><category><![CDATA[Universal Windows App]]></category><category><![CDATA[MVVM Light]]></category><category><![CDATA[Windows 10]]></category><category><![CDATA[MVVM Light Navigation]]></category><category><![CDATA[INavigationService]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sun, 20 Mar 2016 10:59:00 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2016/03/82b7bcdb-1324-465e-a8b7-ae279372c86a-1.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2016/03/82b7bcdb-1324-465e-a8b7-ae279372c86a-1.jpg" alt="Navigation Between Pages Using MVVM Light in Universal Windows Platform(UWP)"><p>This article will help you to setup the basic Navigation with MVVM pattern in a Windows 10 Universal Platform App using MVVM Light Toolkit from Galasoft.</p>

<p>A complete explanation on how to  setup your  first Windows 10 Universal Windows Platform using MVVM Light can be found in this article: <a href="http://www.joeljoseph.net/using-mvvm-light-with-universal-windows-app-for-windows-10/">Using MVVM Light with Universal Windows App For Windows 10</a>.</p>

<h6>Getting Started</h6>  

<p>For now let's hope you have already setup a blank project for Universal Windows Platform with MVVM Light Library installed and completed the basic steps to implement MVVM Light. I have named my solution as <mark>Win10MVVMLightNavigationDemo</mark>.</p>

<p>The App has two Pages <mark>FirstPage.xaml</mark> and <mark>SecondPage.xaml</mark>: <br>
<br> <br>
 <b> FirstPage.xaml</b> 
<img src="http://joeljoseph.net:80/content/images/2018/03/FirstPageView.JPG" alt="Navigation Between Pages Using MVVM Light in Universal Windows Platform(UWP)">
<br> <br>
The Xaml code for the page is:  </p>

<pre><code>&lt;Page  
    x:Class="Win10MVVMLightNavigationDemo.Views.FirstPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10MVVMLightNavigationDemo.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    DataContext="{Binding FirstPageInstance, Source={StaticResource Locator}}" 
    mc:Ignorable="d"&gt;

    &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition Height="1*"/&gt;
            &lt;RowDefinition Height="1*"/&gt;
        &lt;/Grid.RowDefinitions&gt;
        &lt;TextBlock Grid.Row="0" Name="Title" Text="{Binding Title}" FontSize="28" TextAlignment="Center"  VerticalAlignment="Center" HorizontalAlignment="Center" Width="200" Height="50"/&gt;
        &lt;Button Grid.Row="1" Name="Navigate" Command="{Binding NavigateCommand}" Content="Got to Second Page"  VerticalAlignment="Center" HorizontalAlignment="Center" /&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre>

<p>And Now the <b>SecondPage.xaml</b> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/SecondPageView1.JPG" alt="Navigation Between Pages Using MVVM Light in Universal Windows Platform(UWP)">
<br> <br>
The Xaml code for the page is:  </p>

<pre><code>&lt;Page  
    x:Class="Win10MVVMLightNavigationDemo.Views.SecondPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10MVVMLightNavigationDemo.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    DataContext="{Binding SecondPageInstance, Source={StaticResource Locator}}" 
    mc:Ignorable="d"&gt;

    &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition Height="1*"/&gt;
            &lt;RowDefinition Height="1*"/&gt;
        &lt;/Grid.RowDefinitions&gt;
        &lt;TextBlock Grid.Row="0" Name="Title" Text="{Binding Title}" FontSize="28" TextAlignment="Center"  VerticalAlignment="Center" HorizontalAlignment="Center" Width="200" Height="50"/&gt;
        &lt;Button Grid.Row="1" Name="Navigate" Command="{Binding NavigateCommand}" Content="Got to First Page"  VerticalAlignment="Center" HorizontalAlignment="Center" /&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre>

<p>Also there are ViewModel in the <mark>ViewModels</mark> folder for each Page in the App .</p>

<p><b>FirstPageViewModel.cs</b>  </p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Command;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;

namespace Win10MVVMLightNavigationDemo.ViewModels  
{
    public  class FirstPageViewModel : ViewModelBase
    {
        public RelayCommand NavigateCommand { get; private set; }
        private bool _isLoading = false;
        public bool IsLoading
        {
            get
            {
                return _isLoading;
            }
            set
            {
                _isLoading = value;
                RaisePropertyChanged("IsLoading");

            }
        }
        private string _title;
        public string Title
        {

            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    RaisePropertyChanged("Title");
                }
            }
        }

        public FirstPageViewModel()
        {
            Title = "First Page";
            NavigateCommand = new RelayCommand(NavigateCommandAction);
        }

        private void NavigateCommandAction()
        {
            // Do Something
        }
    }
}
</code></pre>

<p>And the <b>SecondPageViewModel.cs</b>  </p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Command;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;

namespace Win10MVVMLightNavigationDemo.ViewModels  
{
    public  class SecondPageViewModel : ViewModelBase
    {
        public RelayCommand NavigateCommand { get; private set; }
        private bool _isLoading = false;
        public bool IsLoading
        {
            get
            {
                return _isLoading;
            }
            set
            {
                _isLoading = value;
                RaisePropertyChanged("IsLoading");

            }
        }
        private string _title;
        public string Title
        {

            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    RaisePropertyChanged("Title");
                }
            }
        }

        public SecondPageViewModel()
        {
            Title = "Second Page";
            NavigateCommand = new RelayCommand(NavigateCommandAction);
        }

        private void NavigateCommandAction()
        {
            //Do Something
        }
    }
}
</code></pre>

<p>The <b> ViewModelLocator.cs</b> for the App which registers each instance of ViewModel Looks like this:  </p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Ioc;  
using GalaSoft.MvvmLight.Views;  
using Microsoft.Practices.ServiceLocation;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;

namespace Win10MVVMLightNavigationDemo.ViewModels  
{
    /// &lt;summary&gt;
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// &lt;/summary&gt; 
    public class ViewModelLocator
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the ViewModelLocator class.
        /// &lt;/summary&gt;
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
            if (ViewModelBase.IsInDesignModeStatic)
            {
                // Create design time view services and models
            }
            else
            {
                // Create run time view services and models
            }

            //Register your services used here
            SimpleIoc.Default.Register&lt;FirstPageViewModel&gt;();
            SimpleIoc.Default.Register&lt;SecondPageViewModel&gt;();


        }


        // &lt;summary&gt;
        // Gets the FirstPage view model.
        // &lt;/summary&gt;
        // &lt;value&gt;
        // The FirstPage view model.
        // &lt;/value&gt;
        public FirstPageViewModel FirstPageInstance
        {
            get
            {
                return ServiceLocator.Current.GetInstance&lt;FirstPageViewModel&gt;();
            }
        }

        // &lt;summary&gt;
        // Gets the SecondPage view model.
        // &lt;/summary&gt;
        // &lt;value&gt;
        // The SecondPage view model.
        // &lt;/value&gt;
        public SecondPageViewModel SecondPageInstance
        {
            get
            {
                return ServiceLocator.Current.GetInstance&lt;SecondPageViewModel&gt;();
            }
        }

        // &lt;summary&gt;
        // The cleanup.
        // &lt;/summary&gt;
        public static void Cleanup()
        {
            // TODO Clear the ViewModels
        }
    }
}
</code></pre>

<p>Also the <b>App.xaml</b> was modified to register  locator as a global static resource to make it  available for all pages to use.</p>

<p><b>App.xaml</b>  </p>

<pre><code>&lt;Application  
    x:Class="Win10MVVMLightNavigationDemo.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10MVVMLightNavigationDemo"
    xmlns:vm="using:Win10MVVMLightNavigationDemo.ViewModels"
    RequestedTheme="Light"&gt;
    &lt;Application.Resources&gt;
        &lt;vm:ViewModelLocator xmlns:vm="using:Win10MVVMLightNavigationDemo.ViewModels" x:Key="Locator" /&gt;
    &lt;/Application.Resources&gt;
&lt;/Application&gt;
</code></pre>

<h6>Using NavigationService</h6>  

<p>In order to use the Navigation in MVVM Light you will have to register and Configure <mark>INavigationService</mark> in <b>ViewModelLocator.cs</b> , for this you will have to register each Page with a  PageKey. </p>

<p>First declare page key variable for each page in the App as a <mark>Public constant string</mark> before initializing  instance of ViewModelLocator Class  </p>

<pre><code>public const string FirstPageKey = "FirstPage";  
public const string SecondPageKey = "SecondPage";  
</code></pre>

<p>Now define a new instance of <mark>NavigationService</mark> and configure it with providing each Page Key for each Page before registering the INavigationService to the <mark>SimpleIoc</mark></p>

<pre><code> var nav = new NavigationService();
            nav.Configure(FirstPageKey, typeof(FirstPage));
            nav.Configure(SecondPageKey, typeof(SecondPage));
</code></pre>

<p>After this register the INavigationService to the ViewModelLocator SimpleIoc  </p>

<pre><code>SimpleIoc.Default.Register&lt;INavigationService&gt;(() =&gt; nav);  
</code></pre>

<p>After all the above steps the <b>ViewModelLoacator.cs</b> will look like this:  </p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Ioc;  
using GalaSoft.MvvmLight.Views;  
using Microsoft.Practices.ServiceLocation;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  
using Win10MVVMLightNavigationDemo.Views;

namespace Win10MVVMLightNavigationDemo.ViewModels  
{
    /// &lt;summary&gt;
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// &lt;/summary&gt; 
    public class ViewModelLocator
    {
        public const string FirstPageKey = "FirstPage";
        public const string SecondPageKey = "SecondPage";
        /// &lt;summary&gt;
        /// Initializes a new instance of the ViewModelLocator class.
        /// &lt;/summary&gt;
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
            var nav = new NavigationService();
            nav.Configure(FirstPageKey, typeof(FirstPage));
            nav.Configure(SecondPageKey, typeof(SecondPage));
            if (ViewModelBase.IsInDesignModeStatic)
            {
                // Create design time view services and models
            }
            else
            {
                // Create run time view services and models
            }

            //Register your services used here
            SimpleIoc.Default.Register&lt;INavigationService&gt;(() =&gt; nav);
            SimpleIoc.Default.Register&lt;FirstPageViewModel&gt;();
            SimpleIoc.Default.Register&lt;SecondPageViewModel&gt;();


        }


        // &lt;summary&gt;
        // Gets the FirstPage view model.
        // &lt;/summary&gt;
        // &lt;value&gt;
        // The FirstPage view model.
        // &lt;/value&gt;
        public FirstPageViewModel FirstPageInstance
        {
            get
            {
                return ServiceLocator.Current.GetInstance&lt;FirstPageViewModel&gt;();
            }
        }

        // &lt;summary&gt;
        // Gets the SecondPage view model.
        // &lt;/summary&gt;
        // &lt;value&gt;
        // The SecondPage view model.
        // &lt;/value&gt;
        public SecondPageViewModel SecondPageInstance
        {
            get
            {
                return ServiceLocator.Current.GetInstance&lt;SecondPageViewModel&gt;();
            }
        }

        // &lt;summary&gt;
        // The cleanup.
        // &lt;/summary&gt;
        public static void Cleanup()
        {
            //  Clear the ViewModels
        }
    }
}
</code></pre>

<p>Now you will have to use INavigationService instance  in your each ViewModel.</p>

<p>Fist take the case of <mark>FirstPageViewModel</mark>  now you will have to declare INaviagtionSevice as Private readonly before initializes a new instance of the  FirstPageViewModel </p>

<p><code>private readonly INavigationService _navigationService;</code> </p>

<p>Also pass the Navigation service as arguments to the   constructor.  </p>

<pre><code> public FirstPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;
            Title = "First Page";
            NavigateCommand = new RelayCommand(NavigateCommandAction);
        }
</code></pre>

<p>Now all that left is to call the <mark>NavigateTo</mark> method and pass the Page Key to Navigate to the <mark>SecondPage</mark> in the <mark>NavigateCommandAction</mark></p>

<p><code>_navigationService.NavigateTo("SecondPage");</code></p>

<p>After all the above steps your <b>FirstPageViewModel.cs</b> Will have the following code:  </p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Command;  
using GalaSoft.MvvmLight.Views;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;

namespace Win10MVVMLightNavigationDemo.ViewModels  
{
    public  class FirstPageViewModel : ViewModelBase
    {
        private readonly INavigationService _navigationService;
        public RelayCommand NavigateCommand { get; private set; }
        private bool _isLoading = false;
        public bool IsLoading
        {
            get
            {
                return _isLoading;
            }
            set
            {
                _isLoading = value;
                RaisePropertyChanged("IsLoading");

            }
        }
        private string _title;
        public string Title
        {

            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    RaisePropertyChanged("Title");
                }
            }
        }

        public FirstPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;
            Title = "First Page";
            NavigateCommand = new RelayCommand(NavigateCommandAction);
        }

        private void NavigateCommandAction()
        {
            // Do Something
            _navigationService.NavigateTo("SecondPage");
        }
    }
}
</code></pre>

<p>For navigating to the <mark>FirstPage</mark> follow the above steps all that you need to change the Page Key to <mark>FirstPage</mark> in NavigateTo method</p>

<p><code>_navigationService.NavigateTo("FirstPage");</code></p>

<p>or if you wish to use the back button feature just replace it  with:</p>

<p><code>_navigationService.GoBack();</code></p>

<p>And your<b>SecondPageViewModel.cs</b> will have the following code :</p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Command;  
using GalaSoft.MvvmLight.Views;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;

namespace Win10MVVMLightNavigationDemo.ViewModels  
{
    public  class SecondPageViewModel : ViewModelBase
    {
        private readonly INavigationService _navigationService;
        public RelayCommand NavigateCommand { get; private set; }
        private bool _isLoading = false;
        public bool IsLoading
        {
            get
            {
                return _isLoading;
            }
            set
            {
                _isLoading = value;
                RaisePropertyChanged("IsLoading");

            }
        }
        private string _title;
        public string Title
        {

            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    RaisePropertyChanged("Title");
                }
            }
        }

        public SecondPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;
            Title = "Second Page";
            NavigateCommand = new RelayCommand(NavigateCommandAction);
        }

        private void NavigateCommandAction()
        {
            //Do Something
            _navigationService.NavigateTo("FirstPage");

            // or use the GoBack if you like to implement a back button functionality

            //_navigationService.GoBack(); 
        }
    }
}
</code></pre>

<p>The following  shows the working of the App: <br>
<img src="http://joeljoseph.net:80/content/images/2016/03/Wroking-1.gif" alt="Navigation Between Pages Using MVVM Light in Universal Windows Platform(UWP)"></p>]]></content:encoded></item><item><title><![CDATA[Converting Hex to Color in C# for Universal Windows Platform (UWP)]]></title><description><![CDATA[<p>If you have developed apps for Universal Windows Platform  there must be situations where you had to convert Hex-code to Color. You must have googled to find the solution , or performed a search in Stack-overflow </p>

<p>The most common solution you find will be some thing like the code below which</p>]]></description><link>http://joeljoseph.net:80/converting-hex-to-color-in-universal-windows-platform-uwp/</link><guid isPermaLink="false">6746d09d-8bd2-4bb2-acac-e0ac4928df28</guid><category><![CDATA[C#]]></category><category><![CDATA[UWP]]></category><category><![CDATA[Universal Windows App]]></category><category><![CDATA[Windows 10]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Mon, 07 Mar 2016 19:49:45 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2016/03/dn469161-homepage_hero_backgrounds.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2016/03/dn469161-homepage_hero_backgrounds.jpg" alt="Converting Hex to Color in C# for Universal Windows Platform (UWP)"><p>If you have developed apps for Universal Windows Platform  there must be situations where you had to convert Hex-code to Color. You must have googled to find the solution , or performed a search in Stack-overflow </p>

<p>The most common solution you find will be some thing like the code below which can be found in the following thread in <a href="http://stackoverflow.com/questions/2109756/how-to-get-color-from-hexadecimal-color-code-using-net">StackOverflow</a>  </p>

<pre><code>using System.Windows.Media;

Color color = (Color)ColorConverter.ConvertFromString("#FFDFD991");  
</code></pre>

<p></p><h6>Or </h6><p></p>

<p>Something  from the following thread from <a href="http://stackoverflow.com/questions/12155811/how-to-convert-hexadecimal-ffffff-to-system-drawing-color">StackOverflow</a>  </p>

<pre><code>string hex = "#FFFFFF";  
Color color = System.Drawing.ColorTranslator.FromHtml(hex);  
</code></pre>

<h6>Above Code Doesn't work for UWP  </h6>

<p>Well in most .net Applications the code above will work , but not in UWP Apps or previous Windows Apps. You may hit dependency error like 'System.drawing namespace not found'  or 'ColorConverter does not exist'.</p>

<p>The issue here isn't the framework version but rather the reduced framework API that is available to Universal Apps. Windows Universal apps don't have the same coverage of namespaces, classes, and APIs as the full .NET framework, and as a result, you can't reuse everything from full .net (such as System.Drawing) in a Universal Project.</p>

<p>However, you don't necessarily have to rewrite the <mark>WHOLE THING</mark>. instead, what you want to do is abstract the platform-specific behavior to an interface, and only that part has to be rewritten.</p>

<p>In otherwords, the global behaviors, UI and interaction can be reused using the classes available in all frameworks, usually represented by a <mark>Portable Class Library (PCL)</mark>, and each version of your app (<b>Winforms</b>, <b>Universal</b>, <b>Xamarin</b>, etc) would reuse that shared library for the "core" of the application and the UI (and platform-specific behavior) would be the only part you would implement separately, in each version of the app you want to support.</p>

<h6>Is there any other way ?</h6>  

<p>If the above explanation got you confused and you just want to convert the hex to Color and don't want to be bothered or to get deep into it just use following method :</p>

<p>Create a method to Convert Hex string to SolidColorBrush:  </p>

<pre><code>public SolidColorBrush GetSolidColorBrush(string hex)  
{
  hex = hex.Replace("#", string.Empty);
  byte a = (byte)(Convert.ToUInt32(hex.Substring(0, 2), 16));
  byte r = (byte)(Convert.ToUInt32(hex.Substring(2, 2), 16));
  byte g = (byte)(Convert.ToUInt32(hex.Substring(4, 2), 16));
  byte b = (byte)(Convert.ToUInt32(hex.Substring(6, 2), 16));
  SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b));
            return myBrush;
}
</code></pre>

<p>Now all that left is to get the color by Calling the method and pass the hex string to it as parameter:  </p>

<pre><code>var color = GetSolidColorBrush("#FFCD3927").Color;  
</code></pre>

<p>Now you have got the color for the hex you have provided.</p>]]></content:encoded></item><item><title><![CDATA[Using  MVVM Light with Universal Windows App For Windows 10]]></title><description><![CDATA[This article will help you to setup the basic MVVM pattern in  a Windows 10 Universal Platform App using MVVM Light Toolkit from Galasoft.]]></description><link>http://joeljoseph.net:80/using-mvvm-light-with-universal-windows-app-for-windows-10/</link><guid isPermaLink="false">4e50cf96-dda9-4115-a671-6d7168686a6c</guid><category><![CDATA[C#]]></category><category><![CDATA[MVVM]]></category><category><![CDATA[UWP]]></category><category><![CDATA[Universal Windows App]]></category><category><![CDATA[MVVM Light]]></category><category><![CDATA[Windows 10]]></category><dc:creator><![CDATA[Joel Joseph]]></dc:creator><pubDate>Sun, 28 Feb 2016 19:03:51 GMT</pubDate><media:content url="http://joeljoseph.net:80/content/images/2016/02/IC808721.png" medium="image"/><content:encoded><![CDATA[<img src="http://joeljoseph.net:80/content/images/2016/02/IC808721.png" alt="Using  MVVM Light with Universal Windows App For Windows 10"><p>This article will help you to setup the basic MVVM pattern in  a Windows 10 Universal Platform App using MVVM Light Toolkit from Galasoft.</p>

<h5>What is MVVM ? </h5>

<p>MVVM (Model-View-ViewModel) is and software architectural pattern which provide a clean separation of concerns between the user interface controls and their logic. There are three core components in the MVVM pattern: the model, the view  and the View Model.Each serves  a distinct and  separate role.</p>

<p><img src="http://joeljoseph.net:80/content/images/2016/02/MVVM.png" alt="Using  MVVM Light with Universal Windows App For Windows 10"></p>

<p>A complete discussion of MVVM pattern is outside the scope of this article so if you are new to the concept and want to learn more I suggest taking a look at articles like this one on MSDN: <a href="https://msdn.microsoft.com/en-us/library/hh848246.aspx">The MVVM Pattern </a></p>

<h5>MVVM Light Toolkit</h5>

<p><a href="http://www.mvvmlight.net/">The MVVM Light Toolkit</a> is an open-source framework for building applications using the MVVM Pattern.The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in WPF, Silverlight, Windows Store, Windows Phone and Xamarin</p>

<p>MVVM Light is a library that i use since its early versions. Many other implementations of the MVVM pattern are available, such as <a href="https://msdn.microsoft.com/en-us/library/ff648465.aspx">Prism</a>, and some developers even choose to roll their own framework.</p>

<h5>Getting Started</h5>  

<p>For starters let me be clear that you need  Windows 10 Pro (to make use Hyper-v to run  emulators) and Visual Studio 2015  as IDE. I suggest you install Visual Studio 2015 Community which is Free Which is Packed with almost all the Features you need for development.</p>

<p><b>Startup</b> Visual Studio 2015 and create a <b>New Project Template</b> under  <b>Visual C#</b>  choose  <b>Windows</b>  then select <b>Blank App (universal Windows )</b>. <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/Step1-2.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br> <br>
Just name your project something like Win10MVVMLightDemo. Visual Studio will create a new Solution with your project  which will look something like this: <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/step1-a.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br> <br>
You can see the new project created  and the default folder structure by looking the <a href="https://msdn.microsoft.com/library/bbck0dh6(v=vs.110).aspx">Solution Explorer</a></p>

<h6>Installing MVVM Light Toolkit</h6>  

<p>There are different ways to install MVVM Light Toolkit , but in this demo  use Nuget.</p>

<p>Before installing MVVM Light Toolkit through nuget i like to inform those who have used MVVM Light Toolkit for Windows 8 and Windows 8.1 (Phone or desktop) Development  that  Nuget team changed the implementation for UWP and decided not to support content files and the powershell script anymore. So the current version of MVVM Light Toolkit (5.2.0) Does not create <b>ViewModelLocator</b> for you, nothing will be  added to resources  and no code is added to App.xaml like it used to. You will have to add these manually.</p>

<p><b>Right Click</b> the project  References in Solution Explorer and on the menu that appears click on Manage Nuget Packages. On the Windows that appears search with keyword 'mvvm light' : <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/nuget-1.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br> <br>
Now make sure you select the MVVM Light Toolkit From Galasoft and click install. This install the MVVM Light Library and its references to the project.While installing it may prompt you asking permission to install components just click  'I Accept' . After installation is complete you can see the reference added to the project under References in Solution Explorer: <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/mvvmlight.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10"></p>

<p>Now Lets Set up the Project Structure since Folders for Views and ViewModels are not added to project resources automatically as used to early in windows 8.1</p>

<p><b>Right Click</b> on the project in Solution Explorer and Add three folders  <b>Models</b> ,<b> Views</b> , <b>ViewModels</b>. <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/Folder.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br> <br>
You may delete or  move the existing page <b>MainPage.xam</b>l to  Views folder. For  now  lets<b> delete</b> it and  add a new item <b>StartPage.xaml</b> in Views folder. Right Click on Views folder and add New Item and select <b>Blank Page</b> name it <b>StartPage.xaml</b>. </p>

<p>Now the new Blank Page will be created in Views folder, since we deleted the default Startup page <b>MainPage.xaml</b> you will now have to scope the App 's Startup  Page to <b>StartPage.xaml</b> in Views folder. To do this  look for <b>App.xaml.cs</b> and search for the word <b>MainPage</b>.</p>

<p>You will find following code under OnLaunched method:</p>

<p><code>rootFrame.Navigate(typeof(MainPage), e.Arguments);</code></p>

<p>Change it to:</p>

<p><code>rootFrame.Navigate(typeof(StartPage), e.Arguments);</code></p>

<p>Also you need to add the following dependency in <b>App.xaml.cs</b> <br>
<code>using Win10MVVMLightDemo.Views;</code> </p>

<p>just press <b> Ctrl</b> + <b>.</b> on the word to bring out the intellisense. <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/app-2.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br></p>

<p>Next we have to Add a new Class <b>ViewModelLocator.cs</b> to the <b>ViewModels</b> folder.</p>

<p>A ViewModelLocator is a class that centralizes the definitions of all the ViewModels in an app so that they can be cached and retrieved on demand, usually via Dependency Injection. ViewModelLocator is an idiom that lets you keep the benefits of DI(Dependency Injection) in your MVVM application while also allowing your code to play well with visual designers. ViewModelLocator needs to setup the IOC provider, register each individual ViewModel, and finally expose those registered ViewModels for use by the rest of the application. A full discussion of these topics also outside the scope of this document, but it's discussed on <a href="http://stackoverflow.com/questions/5462040/what-is-a-viewmodellocator-and-what-are-its-pros-cons-compared-to-datatemplates/5462324#5462324">StackOverflow</a> .</p>

<p><br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/ViewModelLocator.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br></p>

<p>Now replace the code in the <b>ViewModelLocator.cs</b> with the following code :</p>

<pre><code>using GalaSoft.MvvmLight;  
using GalaSoft.MvvmLight.Ioc;  
using GalaSoft.MvvmLight.Views;  
using Microsoft.Practices.ServiceLocation;  
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;

namespace Win10MVVMLightDemo.ViewModels  
{
    /// &lt;summary&gt;
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// &lt;/summary&gt; 
    public class ViewModelLocator
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the ViewModelLocator class.
        /// &lt;/summary&gt;
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
            if (ViewModelBase.IsInDesignModeStatic)
            {
                // Create design time view services and models
            }
            else
            {
                // Create run time view services and models
            }         

            //Register your services used here
            SimpleIoc.Default.Register&lt;INavigationService, NavigationService&gt;();
            SimpleIoc.Default.Register&lt;StartPageViewModel&gt;();

        }


        // &lt;summary&gt;
        // Gets the StartPage view model.
        // &lt;/summary&gt;
        // &lt;value&gt;
        // The StartPage view model.
        // &lt;/value&gt;
        public StartPageViewModel StartPageInstance
        {
            get
            {
                return ServiceLocator.Current.GetInstance&lt;StartPageViewModel&gt;();
            }
        }

        // &lt;summary&gt;
        // The cleanup.
        // &lt;/summary&gt;
        public static void Cleanup()
        {
            // TODO Clear the ViewModels
        }
    }

}
</code></pre>

<p><br> <br>
Now we will add another Class in <b>ViewModles</b> folder <b>StartPageViewModel.cs</b> and replace the code inside with the following: <br>
<br></p>

<pre><code>using GalaSoft.MvvmLight;

namespace Win10MVVMLightDemo.ViewModels  
{
    public class StartPageViewModel : ViewModelBase
    {
        private bool _isLoading = false;
        public bool IsLoading
        {
            get
            {
                return _isLoading;
            }
            set
            {
                _isLoading = value;
                RaisePropertyChanged("IsLoading");

            }
        }
        private string _title;
        public string Title
        {

            get
            {
                return _title;
            }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    RaisePropertyChanged("Title");
                }
            }
        }

        public StartPageViewModel()
        {
            Title = "Hello Joel";
        }
    }
}
</code></pre>

<p><br> <br>
The ServiceLocator is responsible for retrieving the ViewModel instances, using the SimpleIoc.Default implementation provided by MVVM Light. By registering them via the SimpleIoc.Default instance in the constructor, we can retrieve those instances from the Views via the public properties defined in the locator class.</p>

<p>We can then register this <mark>locator</mark> as a global static resource in <b>App.xaml</b> so it is available for all pages to use. These resources are automatically instantiated, both at runtime and designtime, ensuring that both our sample and live data are ready.</p>

<p>Now change the code inside <b>App.xaml</b> to following: <br>
<br>  </p>

<pre><code>&lt;Application  
    x:Class="Win10MVVMLightDemo.App"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10MVVMLightDemo"
    xmlns:vm="using:Win10MVVMLightDemo.ViewModels"
    RequestedTheme="Light"&gt;
    &lt;Application.Resources&gt;
        &lt;vm:ViewModelLocator xmlns:vm="using:Win10MVVMLightDemo.ViewModels" x:Key="Locator" /&gt;
    &lt;/Application.Resources&gt;
&lt;/Application&gt;
</code></pre>

<p><br> <br>
Now we will Edit the <b>StartPage.xaml</b> to add the ViewModel to its appropriate page via the DataContext for this add following code to <b>StartPage.xaml</b> and set the DataContext to <mark>SartPageInstance</mark> that we defined in the <b>ViewModelLocator.cs</b>  : </p>

<p><code>DataContext="{Binding SartPageInstance, Source={StaticResource Locator}}"</code></p>

<p>Also add the Xaml code inside the <mark>Grid View</mark> to display the title of the page that we defined as a property <mark>Title</mark> in the <b>StartPageViewModel.cs </b></p>

<p><code>&lt;TextBlock Name="Title"  HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Title}" FontFamily="Segoe UI Historic" /&gt;</code>
<br> <br>
After adding these codes the <b>StartPage.xaml</b> will look something like this: <br>
<br>  </p>

<pre><code>&lt;Page  
    x:Class="Win10MVVMLightDemo.Views.StartPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Win10MVVMLightDemo.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    DataContext="{Binding StartPageInstance, Source={StaticResource Locator}}" 
    mc:Ignorable="d"&gt;

    &lt;Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
        &lt;TextBlock Name="Title"  HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Title}" FontFamily="Segoe UI Historic" /&gt;
    &lt;/Grid&gt;
&lt;/Page&gt;
</code></pre>

<p><br></p>

<p>Now the  App is ready to <b>Build</b> and <b>Run</b>, You may now build the app and check for <mark>errors</mark>. if error is found make sure you have not left out any of the previous steps</p>

<p>If there are no Errors found on building the solution you may now hit the <b>Play</b> button. You may choose to run you app in <mark>Local Machine</mark>, <mark>Simulator</mark>,or any of the <mark>Emulators</mark>. For now lets choose the <b>local Machine</b> and Run the App. <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/run.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br></p>

<p>Upon running the app in debug Mode in Local Machine the App will look Something like this: <br>
<br> <br>
<img src="http://joeljoseph.net:80/content/images/2018/03/result.JPG" alt="Using  MVVM Light with Universal Windows App For Windows 10">
<br></p>

<p>That's it the App runs, if you find the frame counter in the app annoying you can remove it by commenting out the following code inside <mark>OnLaunched</mark> method in <b>App.xaml.cs</b> <br>
<br>  </p>

<pre><code>#if DEBUG
  if (System.Diagnostics.Debugger.IsAttached)
  {
    this.DebugSettings.EnableFrameRateCounter = true;
  }
#endif
</code></pre>

<p><br></p>]]></content:encoded></item></channel></rss>