Tuesday, March 15, 2016

How to create template as a resource - C# WPF


Templates are generally used to provide common appearance for multiple controls. So they are defined as resources for the re usability.

Please see the example code in folder Chap5Les2 in this link.

https://github.com/Nalani/WPF

This is the output for the code.





Saturday, August 22, 2015

Await and Async keywords in .net 4.5

Moving to .NET 4.5, Async and Await key words are introduced for Asynchronous Programming in C#. Let's have a quick look on what these are.

Async and awit are markers which mark code positions from where control should resume after a task (thread) completes.

See the following example,

1. It goes from Main to Method() and invoked LongTask()
   in a multi threaded way.
2. And code then goes ahead "COnsole.WriteLine("New thread")"



But we want to wait LongTask() to run and then exeute  "Console.WriteLine("New thread")".

So "COnsole.WriteLine("New thread")" this should wait untill LongTask() is done.

So this is what you do with above keywords,



Now , 
after LongTask() is done, "Console.WriteLine("New thread")" line is executed means it waits till 20s and show "New thread" in the console.

Hope you have got the point. !!

reference : www.questpond.com

Wednesday, July 1, 2015

Filtering in Angular Js

This is also a sample from the reference source "AngularJs Fundamentals in 60- ish minutes"  in https://www.youtube.com/watch?v=i9MHigUZKEM

We can do filter using "filter and '|' "
Following example is to filter from group of customers using using the customer name or city name typed in the text box.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app ="">
<head>
    <title>Using AngularJs directives and data binding</title>
</head>
<body data-ng-init ="customers=[{name:'John Smith',city:'Phoneix'},{name:'John Doe', city:'New York'},{name:'John Doe', city:'San Francisco'}]">
    Name:
    <br />
    <input type="text" data-ng-model ="name" /> {{name}}
    <br/>
    <ul>
        <li data-ng-repeat ="cust in customers | filter: name">{{cust.name}} - {{cust.city}}</li>
    </ul>

    <script src="Scripts/angular.min.js"></script>
</body>
</html>