December 19, 2014

Visual Studio Project Type GUIDs Cheet Sheet

Every VS projects have a project type and some of the projects contains more than one type. Each project type is identified by a unique GUID. This GUID is present in the project file for class libraries project while projects like Web Site, GUID is present in the solution file.

Developer require this GUID in order to change the existing project type like suppose you want to change the type from Class Library to Web Application then you need to change its Project Type GUID in order to do so.

The purpose of this post is to list down all the possible Project Type GUIDs which will help developers around the world to convert their projects to desireable choice.

List of Project Type GUIDs are:

1.By Description

  • ASP.NET MVC 1.0 {603C0E0B-DB56-11DC-BE95-000D561079B0}
  • ASP.NET MVC 2.0 {F85E285D-A4E0-4152-9332-AB1D724D3325}
  • ASP.NET MVC 3.0 {E53F8FEA-EAE0-44A6-8774-FFD645390401}
  • ASP.NET MVC 4.0 {E3E379DF-F4C6-4180-9B81-6769533ABE47}
  • C#         {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
  • C++         {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}
  • Database {A9ACE9BB-CECE-4E62-9AA4-C7E7C5BD2124}
  • F#         {F2A71F9B-5D33-465A-A702-920D77279786}
  • J#         {E6FDF86B-F3D1-11D4-8576-0002A516ECE8}
  • Deployment Setup {978C614F-708E-4E1A-B201-565925725DBA}
  • Database (other project types) {4F174C21-8C12-11D0-8340-0000F80270F8}
  • Deployment Cab {3EA9E505-35AC-4774-B492-AD1749C4943A}
  • Deployment Merge Module {06A35CCD-C46D-44D5-987B-CF40FF872267}
  • Deployment Smart Device Cab {AB322303-2255-48EF-A496-5904EB18DA55}
  • Distributed System {F135691A-BF7E-435D-8960-F99683D2D49C}
  • Dynamics 2012 AX C# in AOT {BF6F8E12-879D-49E7-ADF0-5503146B24B8}
  • Legacy (2003) Smart Device (C#) {20D4826A-C6FA-45DB-90F4-C717570B9F32}
  • Legacy (2003) Smart Device (VB.NET) {CB4CE8C6-1BDB-4DC7-A4D3-65A1999772F8}
  • Model-View-Controller v2 (MVC2) {F85E285D-A4E0-4152-9332-AB1D724D3325}
  • Model-View-Controller v3 (MVC3) {E53F8FEA-EAE0-44A6-8774-FFD645390401}
  • Model-View-Controller v4 (MVC4) {E3E379DF-F4C6-4180-9B81-6769533ABE47}
  • Mono for Android {EFBA0AD7-5A72-4C68-AF49-83D382785DCF}
  • MonoTouch {6BC8ED88-2882-458C-8E55-DFD12B67127B}
  • MonoTouch Binding {F5B4F3BC-B597-4E2B-B552-EF5D8A32436F}
  • Portable Class Library {786C830F-07A1-408B-BD7F-6EE04809D6DB}
  • SharePoint (C#) {593B0543-81F6-4436-BA1E-4747859CAAE2}
  • SharePoint (VB.NET) {EC05E597-79D4-47f3-ADA0-324C4F7C7484}
  • SharePoint Workflow {F8810EC1-6754-47FC-A15F-DFABD2E3FA90}
  • Silverlight {A1591282-1198-4647-A2B1-27E5FF5F6F3B}
  • Smart Device (C#) {4D628B5B-2FBC-4AA6-8C16-197242AEB884}
  • Smart Device (VB.NET) {68B1623D-7FB9-47D8-8664-7ECEA3297D4F}
  • Solution Folder {2150E333-8FDC-42A3-9474-1A3956D46DE8}
  • Test {3AC096D0-A1C2-E12C-1390-A8335801FDAB}
  • VB.NET {F184B08F-C81C-45F6-A57F-5ABD9991F28F}
  • Visual Database Tools {C252FEB5-A946-4202-B1D4-9916A0590387}
  • Visual Studio Tools for Applications (VSTA) {A860303F-1F3F-4691-B57E-529FC101A107}
  • Visual Studio Tools for Office (VSTO) {BAA0C2D2-18E2-41B9-852F-F413020CAA33}
  • Web Application {349C5851-65DF-11DA-9384-00065B846F21}
  • Web Site {E24C65DC-7377-472B-9ABA-BC803B73C61A}
  • Windows (C#) {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
  • Windows (VB.NET) {F184B08F-C81C-45F6-A57F-5ABD9991F28F}
  • Windows (Visual C++) {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}
  • Windows Communication Foundation (WCF) {3D9AD99F-2412-4246-B90B-4EAA41C64699}
  • Windows Phone 8/8.1 Blank/Hub/Webview App {76F1466A-8B6D-4E39-A767-685A06062A39}
  • Windows Phone 8/8.1 App (C#) {C089C8C0-30E0-4E22-80C0-CE093F111A43}
  • Windows Phone 8/8.1 App (VB.NET) {DB03555F-0C8B-43BE-9FF9-57896B3C5E56}
  • Windows Presentation Foundation (WPF) {60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}
  • Windows Store (Metro) Apps & Components {BC8A1FFA-BEE3-4634-8014-F334798102B3}
  • Workflow (C#) {14822709-B5A1-4724-98CA-57A101D1B079}
  • Workflow (VB.NET) {D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8}
  • Workflow Foundation {32F31D43-81CC-4C15-9DE6-3FC5453562B6}
  • Xamarin.Android {EFBA0AD7-5A72-4C68-AF49-83D382785DCF}
  • Xamarin.iOS {6BC8ED88-2882-458C-8E55-DFD12B67127B}
  • XNA (Windows) {6D335F3A-9D43-41b4-9D22-F6F17C4BE596}
  • XNA (XBox) {2DF5C3F4-5A5F-47a9-8E94-23B4456F55E2}
  • XNA (Zune) {D399B71A-8929-442a-A9AC-8BEC78BB2433}

2. By GUID

  • Deployment Merge Module {06A35CCD-C46D-44D5-987B-CF40FF872267}
  • Workflow (C#) {14822709-B5A1-4724-98CA-57A101D1B079}
  • Legacy (2003) Smart Device (C#) {20D4826A-C6FA-45DB-90F4-C717570B9F32}
  • Solution Folder {2150E333-8FDC-42A3-9474-1A3956D46DE8}
  • XNA (XBox) {2DF5C3F4-5A5F-47a9-8E94-23B4456F55E2}
  • Workflow Foundation {32F31D43-81CC-4C15-9DE6-3FC5453562B6}
  • Web Application {349C5851-65DF-11DA-9384-00065B846F21}
  • Test {3AC096D0-A1C2-E12C-1390-A8335801FDAB}
  • Windows Communication Foundation (WCF) {3D9AD99F-2412-4246-B90B-4EAA41C64699}
  • Deployment Cab {3EA9E505-35AC-4774-B492-AD1749C4943A}
  • Smart Device (C#) {4D628B5B-2FBC-4AA6-8C16-197242AEB884}
  • Database (other project types) {4F174C21-8C12-11D0-8340-0000F80270F8}
  • SharePoint (C#) {593B0543-81F6-4436-BA1E-4747859CAAE2}
  • ASP.NET MVC 1.0 {603C0E0B-DB56-11DC-BE95-000D561079B0}
  • Windows Presentation Foundation (WPF) {60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}
  • Smart Device (VB.NET) {68B1623D-7FB9-47D8-8664-7ECEA3297D4F}
  • MonoTouch {6BC8ED88-2882-458C-8E55-DFD12B67127B}
  • XNA (Windows) {6D335F3A-9D43-41b4-9D22-F6F17C4BE596}
  • Windows Phone 8/8.1 Blank/Hub/Webview App {76F1466A-8B6D-4E39-A767-685A06062A39}
  • Portable Class Library {786C830F-07A1-408B-BD7F-6EE04809D6DB}
  • C++ {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}
  • Deployment Setup {978C614F-708E-4E1A-B201-565925725DBA}
  • Silverlight {A1591282-1198-4647-A2B1-27E5FF5F6F3B}
  • Visual Studio Tools for Applications (VSTA) {A860303F-1F3F-4691-B57E-529FC101A107}
  • Database {A9ACE9BB-CECE-4E62-9AA4-C7E7C5BD2124}
  • Deployment Smart Device Cab {AB322303-2255-48EF-A496-5904EB18DA55}
  • Visual Studio Tools for Office (VSTO) {BAA0C2D2-18E2-41B9-852F-F413020CAA33}
  • Windows Store Apps (Metro Apps) {BC8A1FFA-BEE3-4634-8014-F334798102B3}
  • C# in Dynamics 2012 AX AOT {BF6F8E12-879D-49E7-ADF0-5503146B24B8}
  • Windows Phone 8/8.1 App (C#)
  •   {C089C8C0-30E0-4E22-80C0-CE093F111A43}
  • Visual Database Tools {C252FEB5-A946-4202-B1D4-9916A0590387}
  • Legacy (2003) Smart Device (VB.NET) {CB4CE8C6-1BDB-4DC7-A4D3-65A1999772F8}
  • XNA (Zune) {D399B71A-8929-442a-A9AC-8BEC78BB2433}
  • Workflow (VB.NET) {D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8}
  • Windows Phone 8/8.1 App (VB.NET)
  •   {DB03555F-0C8B-43BE-9FF9-57896B3C5E56}
  • Web Site {E24C65DC-7377-472B-9ABA-BC803B73C61A}
  • ASP.NET MVC 4.0 {E3E379DF-F4C6-4180-9B81-6769533ABE47}
  • ASP.NET MVC 3.0 {E53F8FEA-EAE0-44A6-8774-FFD645390401}
  • J# {E6FDF86B-F3D1-11D4-8576-0002A516ECE8}
  • SharePoint (VB.NET) {EC05E597-79D4-47f3-ADA0-324C4F7C7484}
  • Xamarin.Android / Mono for Android {EFBA0AD7-5A72-4C68-AF49-83D382785DCF}
  • Distributed System {F135691A-BF7E-435D-8960-F99683D2D49C}
  • VB.NET {F184B08F-C81C-45F6-A57F-5ABD9991F28F}
  • F# {F2A71F9B-5D33-465A-A702-920D77279786}
  • MonoTouch Binding {F5B4F3BC-B597-4E2B-B552-EF5D8A32436F}
  • ASP.NET MVC 2.0 {F85E285D-A4E0-4152-9332-AB1D724D3325}
  • SharePoint Workflow {F8810EC1-6754-47FC-A15F-DFABD2E3FA90}
  • C# {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

December 18, 2014

Typical Traps In WPF

In WPF, few traps are present where developers required lots of time to resolve issues. In this post I'm going to list down the common errors arise in development and their solution so that developer would resolve them quickly.

1. Layout Section


Q1. Scrollbar is not active or visible
Ans. If your control is within a vertical stackpanel, it gives the control infinite height to layout. Consider replacing the stackpanel by a dockpanel.

Q2. I created a data template and set HorizontalAlignment to Stretch but the item is not stretched
Ans. Set the HorizontalContentAlignment on the list to Stretch.

2. DataBinding


Q1. I changed a value, but the binding is not reflecting my changes
Ans. Check the following conditions:
         a. Check the output window in VisualStudio, if there are any binding errors.
         b. Does your data support INotifyPropertyChanged?
         c. Just firing a PropertyChanged event without changing the data does not work. Because the binding checks if oldvalue != newvalue

3. Performance


Q1. My list of items takes too long to render
Ans. Your list is not virtualized. This means, all items will be generated, even if they are not visible. To avoid this check the following points:
         a. ScrollViewer.CanContentScrol must be set to False
         b. Grouping must be disabled
         c. You replaced the ItemsPanel by one that does not support virtualization
         d. You are using a too complex data template.

Q2. Animations cause a high CPU load
Ans. WPF cannot use hardware acceleration and does software rendering. This can be because of the following points:
         a. You have set AllowTransparency to True on your window.
         b. You are using legacy BitmapEffects instead of fast pixel shaders (Effects).
         c. Your graphics adapter or driver does not support DirectX

4. Custom Controls

Q1. I created a custom control, but the template it not showing
Ans. Check the following conditions:
         a. Check if you have overriden the metadata of the DefaultStyleKeyProperty and set it to your type.
         b. Check if your template is surrounded by a style and both have the right TargetType
         c. Check if the resource dictionary that contains the default style is loaded

Q2. I use {TemplateBinding} in my ControlTemplate, but is not working
Ans. Check the following conditions:
         a. In most cases you have to replace {TemplateBinding Property} by {Binding Property RelativeSource={RelativeSource TemplatedParent}}
         b. You can only use TemplateBinding within the content of your control template. It will not work anywhere else!
         c. If you want to access a parent property in the trigger, you have to use a normal binding, with relative source Self.
         d. TemplateBinding works only within the VisualTree of the template. You cannot use it on items that are only in the logical tree. Neighter on Freezables or to do two-way binding.

December 10, 2014

Extremely Helpful Extension Methods in C#

Developers consumed lots of time before C# 3.0 to write methods but after C# 3.0, Microsoft introduces the terminology called "Extension Method" that is saving lots of developer time. Now they have to called these methods to done the matters quickly.

As per Microsoft's correspondence, Extension Methods allow you to create new functionality for existing types without modifying the actual type itself. Extension methods should contains these attributes: 

a. The class has to be static.
b. The method has to be static.
c. The method's first parameter in the signature must have the "this" declared.

You can create your own extension methods which will helps you throughout project and you can easily return the desire result by passing the method name. 

Under below are list of powerful extension methods that will save your lots of development time.

As per rule (a), class has to be static so create static class and then place all the custom extension methods there; I created the custom Extension Method class as:


public static class CustomExtensionMethods
{

}

As per rule (b, c), following custom extension method can reduce lots of your development time efforts.

1. Calculate Age:
    To calculate how old someone is:


public static int CalculateAge(this DateTime dateTime)
{
    var age = DateTime.Now.Year - dateTime.Year;

    if (DateTime.Now < dateTime.AddYears(age))
    {
        age--;
    }

    return age;
}

2. Has<T>()/Is<T>()/Add<T>()/Remove<T>()
   When you required an enumerated type are like flags instead of full items then use the following method:


public static bool Has<T>(this System.Enum type, T value)
{
    try
    {
        return (((int)(object)type & (int)(object)value) == (int)(object)value);
    }
    catch
    {
        return false;
    }
}

public static bool Is<T>(this System.Enum type, T value)
{
    try
    {
        return (int)(object)type == (int)(object)value;
    }
    catch
    {
        return false;
    }
}

public static T Add<T>(this System.Enum type, T value)
{
    try
    {
        return (T)(object)(((int)(object)type | (int)(object)value));
    }
    catch (Exception ex)
    {
        throw new ArgumentException(
            string.Format("Could not append value from enumerated type '{0}'.",
                typeof(T).Name), ex);
    }
}

public static T Remove<T>(this System.Enum type, T value)
{
    try
    {
        return (T)(object)(((int)(object)type & ~(int)(object)value));
    }
    catch (Exception ex)
    {
        throw new ArgumentException(
            string.Format("Could not remove value from enumerated type '{0}'.",
                typeof(T).Name), ex);
    }
}

3. ToReadableTime()
   This method is useful when you required to display a message like 'One second ago'.


public static string ToReadableTime(this DateTime value)
{
    var timeSpan = new TimeSpan(DateTime.UtcNow.Ticks - value.Ticks);
    double totalSecond = timeSpan.TotalSeconds;

    if (totalSecond < 60)
    {
        return timeSpan.Seconds == 1 ? "one second ago" : timeSpan.Seconds + " seconds ago";
    }

    if (totalSecond < 120)
    {
        return "a minute ago";
    }

    if (totalSecond < 2700) // 45 * 60
    {
        return timeSpan.Minutes + " minutes ago";
    }

    if (totalSecond < 5400) // 90 * 60
    {
        return "an hour ago";
    }

    if (totalSecond < 86400) // 24 * 60 * 60
    {
        return timeSpan.Hours + " hours ago";
    }

    if (totalSecond < 172800) // 48 * 60 * 60
    {
        return "yesterday";
    }

    if (totalSecond < 2592000) // 30 * 24 * 60 * 60
    {
        return timeSpan.Days + " days ago";
    }

    if (totalSecond < 31104000) // 12 * 30 * 24 * 60 * 60
    {
        int months = Convert.ToInt32(Math.Floor((double)timeSpan.Days / 30));
        return months <= 1 ? "one month ago" : months + " months ago";
    }

    var years = Convert.ToInt32(Math.Floor((double)timeSpan.Days / 365));
    return years <= 1 ? "one year ago" : years + " years ago";
}

4. WorkingDay()/IsWeekend()/NextWorkday()
   When you want to display like 'Today is working day, weekend or determine the next working day' then:


public static bool WorkingDay(this DateTime date)
{
    return date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday;
}

public static bool IsWeekend(this DateTime date)
{
    return date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday;
}

public static DateTime NextWorkday(this DateTime date)
{
    var nextDay = date;

    while (!nextDay.WorkingDay())
    {
        nextDay = nextDay.AddDays(1);
    }

    return nextDay;
}

5. Next()
   Determine the Next date by passing in a DayOfWeek (i.e. From this date, when is the next Tuesday?)


public static DateTime Next(this DateTime current, DayOfWeek dayOfWeek) 
{ 
    int offsetDays = dayOfWeek - current.DayOfWeek; 

    if (offsetDays <= 0) 
    { 
       offsetDays += 7; 
    } 

    DateTime result = current.AddDays(offsetDays); 
    return result; 
}

6. str.ToStream()/stream.ToString()/CopyTo()
   If you want to take a large string and convert it to a Stream or vice-versa then use these:


public static Stream ToStream(this string str)
{
    byte[] byteArray = Encoding.UTF8.GetBytes(str);
    return new MemoryStream(byteArray);
}

public static string ToString(this Stream stream)
{
    var reader = new StreamReader(stream);
    return reader.ReadToEnd();
}

public static void CopyTo(this Stream fromStream, Stream toStream)
{
    if (fromStream == null)
    {
        throw new ArgumentNullException("fromStream");
    }

    if (toStream == null)
    {
        throw new ArgumentNullException("toStream");
    }
    
    var bytes = new byte[8092];
    int dataRead;

    while ((dataRead = fromStream.Read(bytes, 0, bytes.Length)) > 0)
    {
        toStream.Write(bytes, 0, dataRead);
    }
}

7. Between()   
   Check to see if a date is between two dates. 


public static bool Between(this DateTime dateTime, DateTime rangeStart, DateTime rangeEnd)
{
    return dateTime.Ticks >= rangeStart.Ticks && dateTime.Ticks <= rangeEnd.Ticks;
}

8.RemoveLast() / RemoveLastCharacter() / RemoveFirst() / RemoveFirstCharacter()
   These tricky method save lot of time in the heat of string manipulation. 


public static string RemoveLastCharacter(this String str)
{
    return str.Substring(0, str.Length - 1);
}

public static string RemoveLast(this String str, int number)
{
    return instr.Substring(0, instr.Length - number);
}

public static string RemoveFirstCharacter(this String instr)
{
    return str.Substring(1);
}

public static string RemoveFirst(this String str, int number)
{
    return str.Substring(number);
}

9. ToFileSize
   If you want to read the file of size then this method is easier to read the file size.


public static string ToFileSize(this long size)
{
    if (size < 1024) { return (size).ToString("F0") + " bytes"; }
    if (size < Math.Pow(1024, 2)) { return (size / 1024).ToString("F0") + "KB"; }
    if (size < Math.Pow(1024, 3)) { return (size / Math.Pow(1024, 2)).ToString("F0") + "MB"; }
    if (size < Math.Pow(1024, 4)) { return (size / Math.Pow(1024, 3)).ToString("F0") + "GB"; }
    if (size < Math.Pow(1024, 5)) { return (size / Math.Pow(1024, 4)).ToString("F0") + "TB"; }
    if (size < Math.Pow(1024, 6)) { return (size / Math.Pow(1024, 5)).ToString("F0") + "PB"; }

    return (size / Math.Pow(1024, 6)).ToString("F0") + "EB";
}

10. ToXmlDocument()/ToXDocument()
    This extension method is very handy and will save you a load of time when you need to convert an XmlDocument into an XDocument and vice-versa:


public static XmlDocument ToXmlDocument(this XDocument xDocument)
{
    var xmlDocument = new XmlDocument();

    using (var xmlReader = xDocument.CreateReader())
    {
        xmlDocument.Load(xmlReader);
    }

    return xmlDocument;
}

public static XDocument ToXDocument(this XmlDocument xmlDocument)
{
    using (var nodeReader = new XmlNodeReader(xmlDocument))
    {
        nodeReader.MoveToContent();
        return XDocument.Load(nodeReader);
    }
}

public static XmlDocument ToXmlDocument(this XElement xElement)
{
    var stringBuilder = new StringBuilder();
    var xmlWriterSettings = new XmlWriterSettings {OmitXmlDeclaration = true, Indent = false};

    using (var xmlWriter = XmlWriter.Create(stringBuilder, xmlWriterSettings))
    {
        xElement.WriteTo(xmlWriter);
    }

    var xmlDocument = new XmlDocument();
    xmlDocument.LoadXml(stringBuilder.ToString());
    return xmlDocument;
}

public static Stream ToMemoryStream(this XmlDocument xmlDocument)
{
    var memoryStream = new MemoryStream();
    xmlDocument.Save(memoryStream);
    memoryStream.Flush();//Adjust this if you want read your data 
    memoryStream.Position = 0;
    return memoryStream;
}

Hope these custom extension methods will helps you to reduce your development time and efforts. Stay tuned!

November 12, 2014

Getting started with WPF

Windows Presentation Foundation (WPF) is a new GUI framework of Microsoft as compare with Win Forms. 

Graphical User Interface (GUI) allows you to create an application with the wide variety of GUI controls.

For .NET developers the more interesting frameworks are WinForms and WPF. WPF is the newest GUI framework by Microsoft and developer have a choice to use either WinForms or WPF because Microsoft still support the earlier version GUI framework called "WinForms".

Both frameworks serves the same purpose but still there is LOT of differences between them like major difference is that The WinForms is a layer on top of the standard windows control while WPF is build from scratch and doesn't relies on windows control.

This is the just one difference but when you will start working on WPF, you'll see many more differences. Let me give you some advantages of both frameworks

WPF Advantages:

1. It's more flexible, so you can do more things without having to write or buy new controls.
2. Uses hardware acceleration for drawing the GUI, for better performance.
3. It allows you to make user interfaces for both Windows applications and web applications.

WinForms Advantages:

1. It's older and thereby more tried and tested.
2. There are already a lot of 3rd party controls that you can buy or get for free.
3. The designer in Visual Studio is still, as of writing, better for WinForms than for WPF, where you will have to do more of the work yourself with WPF.

Now back to WPF, it is a combination of XAML (markup) and C#/VB.NET/any other .NET language. XAML, which stands for eXtensible Application Markup Language, is Microsoft's variant of XML for describing a GUI.

So let get started with very basic and most popular example "Hello, World!".

In Visual Studio, click on New project from the File menu. On the left, focus on C# and select  Windows from tree. Now from right panel you can see "WPF Application" template. Select a WPF Application and named the project as "HelloWorld", then press the Ok button.

Now once project is created successfully, open the "MainWindow.xaml". MainWindow.xaml is the primary window of this project whenever you run the application it will show there unless you change this to another window.

Default XAML code of MainWindow.xaml file will look like this:


<Window x:Class="HelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
</Window>

Here we want to display the "Hello, World!" text whenever application load, so place the text there in window as:

<Window x:Class="HelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Main Window" Height="350" Width="525">
    <Grid>
        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="72">
            Hello, World!
        </TextBlock>
    </Grid>
</Window>
Try running the application now (select Debug -> Start debugging or press F5) and see the beautiful result of your hard work - your first WPF application. 

In future, I'll post the more tutorials related to WPF and those will help you to learn the WPF quickly. Let me know if any query remains. Cheers!

September 16, 2014

Story about Imran Khan

ﺑﺎﮐﺴﺘﺎﻧﯿﻮ ﻭﮦ 103 ﺑﺨﺎﺭ ﻣﯿﮟ ﺗﭗ ﺭﮨﺎ ﺗﮭﺎ ، ﻭﮦ ﮔﺰﺷﺘﮧ ﭼﺎﻟﯿﺲ ﮔﮭﻨﭩﻮﮞ ﺳﮯ ﺳﻔﺮ ﻣﯿﮟ ﺗﮭﺎ ﺍﯾﮏ ﺁﻧﮑﮫ ﻧﮩﯿﮟ ﺳﻮﯾﺎ ﻭﮦ ﺑﺎﺭﺵ ﻣﯿﮟ ﺑﮭﯿﮓ ﮐﺮ ﻣﺰﯾﺪ ﺑﯿﻤﺎﺭ ﮨﻮ ﮔﯿﺎ ﺗﮭﺎ. ﻟﯿﮑﻦ ﺳﻮﭼﻨﮯ ﮐﯽ ﺑﺎﺕ ﯾﮧ ﮨﮯ ﮐﮧ ﻭﮦ ﮐﺲ ﮐﮯ ﻟﯿﺌﮯ ﻭﮨﺎﮞ ﮐﮭﮍﺍ ﺗﮭﺎ ؟ ﺍﭘﻨﮯ ﻟﯿﺌﮯ ؟ ﺍﺱ ﮐﮯ ﭘﺎﺱ ﮐﺲ ﭼﯿﺰ ﮐﯽ ﮐﻤﯽ ﮨﮯ ؟

 ﺁﺝ ﺍﮔﺮ ﻭﮦ ﮐﺴﯽ ﺳﭙﻮﺭﭨﺲ ﭼﯿﻨﻞ ﮐﮯ ﻟﯿﺌﮯ ﺁﺭﭨﯿﮑﻞ ﻟﮑﮭﮯ ﯾﺎ ﭼﻨﺪ ﻣﯿﭽﺰ ﻣﯿﮟ ﮐﻤﻨﭩﺮﯼ ﮐﺮ ﺩﮮ ﺗﻮ ﻻﮐﮭﻮ ﮈﺍﻟﺮ ﺍﻭﺭ ﭘﻮﻧﮉ ﮐﻤﺎ ﺳﮑﺘﺎ ﮨﮯ ﮔﮭﺮ ﺑﯿﭩﮭﮯ ﮨﻮﺋﮯ , ﻭﮦ ﮔﮭﺮ ﺑﯿﭩﮫ ﮐﺮ ﭘﯿﺴﮯ ﮐﻤﺎ ﺳﮑﺘﺎ ﮨﮯ ﺍﺱ ﺳﮯ ﻧﮧ ﺗﻮ ﮐﻮﺋﯽ ﺍﺳﮑﯽ ﮐﺮﺩﺍﺭ ﮐﺸﯽ ﮐﺮﮮ ﮔﺎ ﻧﮧ ﮐﻮﺋﯽ ﭘﭩﻮﺍﺭﯼ ﺍﺳﮯ ﮔﺎﻟﯿﺎﮞ ﺩﮮ ﮔﺎ , ﻧﮧ ﮐﻮﺋﯽ ﺍﺱ ﭘﺮ ﺟﮭﻮﭨﮯ ﺍﻭﺭ ﻣﻦ ﮔﮭﮍﺕ ﺍﻟﺰﺍﻡ ﻟﮕﺎﺋﮯ ﮔﺎ .ﻭﮦ ﺁﺭﺍﻡ ﺳﮯ ﺑﯿﭩﮫ ﮐﺮ ﻋﯿﺎﺷﯽ ﺳﮯ ﺁﺳﻮﺩﮦ ﺯﻧﺪﮔﯽ ﮔﺰﺍﺭ ﺳﮑﺘﺎ ﮨﮯ 

 ﻣﮕﺮ ﻭﮦ ﺩﻥ ﺭﺍﺕ ﺧﻮﺍﺭ ﮨﻮ ﺭﮨﺎ ﮨﮯ ﭨﮑﮯ ﭨﮑﮯ ﮐﻮ ﻟﻮﮔﻮﮞ ﮐﯽ ﮔﺎﻟﯿﺎﮞ ﺳﻦ ﺭﮨﺎ ﮨﮯ ﺍﺳﮑﯽ ﮐﺮﺩﺍﺭ ﮐﺸﯽ ﮐﯽ ﺟﺎ ﺭﮨﯽ ﮨﮯ ﺩﻥ ﺭﺍﺕ ﺍﺱ ﭘﺮ ﮨﺎﺗﮫ ﺑﮭﺮ ﺑﮭﺮ ﮐﮯ ﮐﯿﭽﮍ ﺍﭼﮭﺎﻻ ﺟﺎ ﺭﮨﺎ ﮨﮯ  ، ﻃﺮﺡ ﻃﺮﺡ ﮐﮯ ﮔﮭﭩﯿﺎ ﺍﻟﺰﻣﺎﺕ ﻟﮕﺎﺋﮯ ﺟﺎ ﺭﮨﮯ ﮨﯿﮟ ﺟﻦ ﮐﻮ ﮔﻠﯽ ﮐﺎ ﮐﺘﺎ ﻧﮩﯿﮟ ﺟﺎﻧﺘﺎ ﺁﺝ ﻭﮦ ﺍﺱ ﺍﻧﺴﺎﻥ ﮐﻮ ﮔﺎﻟﯿﺎﮞ ﺩﮮ ﺭﮨﮯ ﮨﯿﮟ ﺍﺱ ﺍﻧﺴﺎﻥ ﮐﻮ ﺟﺲ ﻧﮯ ﺍﺱ ﻣﻠﮏ ﮐﮯ ﻟﯿﮯ ﺍﭘﻨﯽ ﺯﻧﺪﮔﯽ ﺩﺍﺅ ﭘﺮ ﻟﮕﺎ ﺩﯼ ﺍﺱ ﺍﻧﺴﺎﻥ ﮐﻮ ﮔﺎﻟﯿﺎﮞ ﺩﮮ ﺭﮨﮯ ﮨﯿﮟ ﺟﺲ ﻧﮯ ﺍﺱ ﻣﻠﮏ ﮐﻮ ﮐﯿﻨﺴﺮ ﺍﺳﭙﺘﺎﻝ ﺟﯿﺴﺎ ﺍﺩﺍﺭﮦ ﺑﻨﺎ ﮐﺮ ﺩﯼ ﺍﺱ ﮐﺎ ﺟﺮﻡ ﯾﮩﯽ ﮨﮯ ﮐﮧ ﻭﮦ ﮐﺮﭘﺸﻦ ﮐﮯ ﺧﻼﻑ ﺑﺎﺕ ﮐﺮﺗﺎ ﮨﮯ

 ﺍﺳﮑﺎ ﺟﺮﻡ ﯾﮩﯽ ﮨﮯ ﮐﮧ ﻭﮦ ﮐﮩﺘﺎ ﮨﮯ ﮐﮧ ﻟﻮﭨﯽ ﮨﻮﺋﯽ ﺩﻭﻟﺖ ﻭﺍﭘﺲ ﻣﻠﮏ ﻣﯿﮟ ﻻﺋﯽ ﺟﺎﮰ ﺍﻭﺭ ﻋﻮﺍﻡ ﭘﺮ ﺧﺮﭺ ﮐﯽ ﺟﺎﮰ ﺍﺳﮑﺎ ﺟﺮﻡ ﯾﮧ ﮨﮯ ﮐﮧ ﻭﮦ ﮐﮩﺘﺎ ﮨﮯ ﮐﮧ ﻋﻮﺍﻡ ﮐﮯ ﭨﯿﮑﺲ ﮐﺎ ﭘﯿﺴﮧ ﻭﺍﻡ ﭘﺮ ﺧﺮﭺ ﮐﯿﺎ ﺟﺎﮰ . ﺍﺳﮑﺎ ﺟﺮﻡ ﯾﮧ ﮨﮯ ﮐﮧ ﻭﮦ ﭼﺎﮨﺘﺎ ﮨﮯ ﮐﮧ ﺍﻣﺮﯾﮑﮧ ﺍﻭﺭ ﺩﻭﺳﺮﮮ ﻣﻤﺎﻟﮏ ﮐﯽ ﻏﻼﻣﯽ ﮐﺎ ﻃﻮﻕ ﮔﻠﮯ ﺳﮯ ﺍﺗﺎﺭﺍ ﺟﺎﮰ ﺍﺳﮑﺎ ﺟﺮﻡ ﯾﮩﯽ ﮨﮯ ﮐﮧ ﻭﮦ ﮐﮩﺘﺎ ﮨﮯ ﮐﮧ ﺑﯿﺮﻭﻧﯽ ﻗﺮﺿﮯ ﺑﻨﺪ ﮐﺮ ﺍﯾﮏ ﻣﻠﮑﯽ ﻭﺳﺎﺋﻞ ﮐﻮ ﺑﺮﻭﺋﮯ ﮐﺎﺭ ﻟﯿﺎ ﺟﺎﮰ ﺍﺳﮑﮯ ﺟﺮﺍﺋﻢ ﮐﯽ ﻓﮩﺮﺳﺖ ﺑﮩﺖ ﻟﻤﺒﯽﮨﮯ ﺩﻭﺳﺘﻮ ﮐﺎﺵ ﮐﮧ ﯾﮧ ﺟﺮﺍﺋﻢ ﺍﺱ ﻣﻠﮏ ﮐﺎ ﮨﺮ ﻓﺮﺩ ﮐﺮﮮ ﺗﻮ ﯾﮧ ﻣﻠﮏ ﺟﻨﺖ ﺑﮯ ﻧﻈﯿﺮ ﺑﻦ ﺟﺎﮰ ﮐﺎﺵ ﮐﮧ ﺍﯾﺴﮯ ﻣﺠﺮﻡ ﭘﺎﮐﺴﺘﺎﻥ ﻣﯿﮟ ﺳﺒﮭﯽ ﮨﻮ ﺟﺎﺋﯿﮟ ﺗﻮ ﯾﮧ ﻣﻠﮏ ﺩﻧﯿﺎ ﭘﺮ ﺭﺍﺝ ﮐﺮﮮ  

September 15, 2014

C# 6 Language Enhancements

Here I'd like to discuss some new features in C# 6, the upcomming version of C# that will ship with next version of Visual studio. The initial buzz about the next version of C# is that C# compiler complete rewrite, written in C# from ground up. C# 6 gives you a lot of features that enhance your productivity both writing and reading C# code.

1. PRIMARY CONSTRUCTORS:


C# 6 introduces the "Primary Constructor" concept, a way to express an initializing constructor in more concise syntax. 

===========
NEW WAY:
===========

public class Person(string first, string last) 
{
     public string First { get; } = first;
     public string Last { get; } = last;
}

===============
CURRENT WAY:
===============

public class Person
{
     private string first;
     private string last;

     public Person(string first, string last)
     {
         this.first = first;
         this.last = last;
     }

     public string First { get { return first; } }
     public string Last { get { return last; } }
}

2. AUTO PROPERTY INITIALIZERS:


Another good feature C# 6 introduce is "Auto Property Initializer", syntax for initializing properties to set constant values on any property.

=========
NEW WAY:
=========

public class Person
{
     public string First { get; set; } = "Jane";
     public string Last { get; set;} = "Doe";

And, it works on read only properties:

public class Person
{
     public string First { get; } = "Jane";
     public string Last { get; } = "Doe";
}

3. MATH CLASS: 


C# 6 introduces the "MATH" class - a single class instead of entire namespace. It’s another small language change that removes some friction in writing and reading code.

using System.Math;

Once you add that, you can reference any members of the System.Math class without any namespace or class qualifer:

var x = Sqrt(3*3 + 4*4);

4. DICTIONARY INITIALIZERS: 


C# 6 introduced a feature called "Lightweight dynamic" the feature that has changed names as it was refined. The concept is grab from JavaScript and JSON language and this feature allow C# to create DTOs (data transfer objects) in much lighter way rather than going through the overhead of creating a strongly typed class that had no behavior.

5. EXCEPTION FILTERS: 


This feature brings C# up to parity with VB.NET. They work as follows:

try 
   // … 
} catch (MyException e) if (myfilter(e)) 
{
    // … 

The catch clause will only be executed if myfilter(e) returns true. Otherwise, any catch clauses that follow are evaluated, or the exception propagates up the call stack.

September 12, 2014

Difference Between A Resume, Bio-Data & CV

1. BIO DATA: 

One page consisting attributes, hobbies, interests and educational qualification of person.

2. RESUME  : 
One to two pages "summary" of skills, education qualification and experience of person.

3. CV      : 
A longer, more detailed synopsis, indicating professional experience of a person.

September 1, 2014

WCF and ASP.NET Web API

WCF


ASP.NET Web API

Enables building services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between them.
HTTP only. First-class programming model for HTTP. More suitable for access from various browsers, mobile devices etc enabling wide reach.
Enables building services that support multiple encodings (Text, MTOM, and Binary) of the same message type and allows switching between them.
Enables building Web APIs that support wide variety of media types including XML, JSON etc.
Supports building services with WS-* standards like Reliable Messaging, Transactions, Message Security.
Uses basic protocol and formats such as HTTP, WebSockets, SSL, JQuery, JSON, and XML. There is no support for higher level protocols such as Reliable Messaging or Transactions.
Supports Request-Reply, One Way, and Duplex message exchange patterns.
HTTP is request/response but additional patterns can be supported through SignalRand WebSockets integration.
WCF SOAP services can be described in WSDL allowing automated tools to generate client proxies even for services with complex schemas.
There is a variety of ways to describe a Web API ranging from auto-generated HTML help page describing snippets to structured metadata for OData integrated APIs.
Ships with the .NET framework.
Ships with .NET framework but is open-source and is also available out-of-band as independent download.

August 27, 2014

6 Key Points Helps You Better Start First Day At Work!

First day at work is like your first day in school. Sometimes people get nervous on 1st day relate to office environment and meet with different culture peoples. I'd like to share few points which helps you to make a better start.

1. Punctual: Make provisions to complete the task before hand; punctuality speaks volume. Being an early comer and an on-time departer adds to the impression, it shows your commitment towards work.

2. Proper Dress: Physical appearance will matter in order to communicate with others in office. When you are in college or university, you could simply wake up and grab unwashed jeans and it could still 'look' appropriate. But when you are work in office then that is not appropriate.

3. Silent the Phone: Activate the silent mode of your phone. Your phone messages can wait, if there is something urgent then you will receive a call. Continuously reply messages is a sign of restlessness and is considered rude when you are in meeting with your colleagues.

4. Be Positive: Be grateful, not just in your verbal interactions but also thank everybody who helped you out. Its not necessary to keep a smile plastered to you face, but be interactive. Do not say you ‘cannot do’ something because you haven’t even taken up a project yet.

5. Listen & Observe: Always be patience and to wait, watch, absorb and then respond. Put off being ‘Mr-Know-It-All’ and control the urge to voice your opinion unless asked for, especially if you do not have any knowledge and there are two seniors deep in a conversation.

6. Ask questions: The biggest mistake one can do is to silently and dumbly follow without knowing why! If you have any queries, make a list and find a person who would be suitable to address them. Do not hold back and hesitate because if you do not understand the concept, you will be absolutely blank while executing in the future.

August 26, 2014

The Ten People You Need in Your Network to Accelerate Your Career

There are many ways to advance your career, but it is rarely a straight path. You can advance your career by staying with one company and methodically climbing up the ladder, although this method is on the downswing.

You can advance your career by leaving companies every 3 to 5 years. Or you can quit your job and start your own company, which often leads to new career opportunities, even if the company fails.

In reviewing my career, I’ve realized that there are certain types of people that have consistently helped me advance to the next level. I’ve been able to use them as sounding boards and ask questions that I normally wouldn't ask, and they’d provide honest feedback. This was extremely important. These are the ten people you need to have relationships with in order to accelerate your career:

CAREER COACH - Someone who has already done what you WANT to do, or someone who is advancing their career without being overworked. Overworked people are not good people to talk to.

FINANCIAL ADVISOR - Someone who lives the life you want to live and is better at saving and investing money than you are. Ideally this is someone who makes less money than you but lives a "better" life. This person doesn’t have to be a professional financial advisor - just someone who is good at it.

AUTHOR / BLOGGER - Someone who has written a book, or who blogs consistently. It's important to watch them as they handle criticism of their work. Writing in public opens you up to criticism, and the best writers respond to that criticism constructively

CEO / VP OF A LARGE COMPANY - Someone who manages big accounts or big teams for a large company. These resources are obviously the toughest to make a connection and build a relationship with unless you have one already. If you do get the chance, it is important to try to build a relationship with them. These resources know how business works and can give you insight into navigating large companies.

ENTREPRENEUR - STARTER - Someone who has started something from scratch and still works on it. I find that these types of people motivate me to keep going. It's also great to keep your ears and eyes close to the startup scene.

ENTREPRENEUR - SUCCESSFUL - Someone who has started and built a successful company. Ideally they have given multiple talks on their success or how to be successful. You can learn a lot from these types of people and many of the successful entrepreneurs WANT to give back.

NON TRADITIONAL CAREER - Someone who doesn't have a traditional job (i.e. who travels and works remotely. Has no home.) I have always been amazed by this type of person. They’ve figured out how to manage their finances and earn an income without having to go to the same office every day. Ask them how they do it.

SPOUSE - Someone you get along with and who doesn't hate you. Someone that listens to you! I would be nowhere if my wife weren’t supportive of me. I'm very happy that my wife supports my work.

RESOURCEFUL TECH GUY/GIRL - Someone you can call with any tech question. NOT the guy you call to ask, “My computer is broken. Can you fix it?” The one you ask, "How would I create a super simple website for my business?" type of question that tech guys can answer. Tech people are slowly taking ove the world. There are resources online for almost anything that you are looking to accomplish.

SUPER CONNECTOR - Someone who knows everyone or can get you to someone who knows someone quickly. If you build a great relationship with a super connector, finding the above people will become much easier! Obviously, you have to have something to offer to entice the super connector to connect you with others who can help you.

The core principal of all these types is that they must have energy and integrity. Integrity in the business world is a must, but you will find plenty of people who do not believe that mantra. Have integrity in everything you do and surround yourself with others who believe in living a life with integrity.

Author: Robbie A.