Converter to hide items when something is null or empty string

Often times in Xaml you’ve got some labels, or buttons that you don’t want to show if something in the ViewModel is null or empty. Take the example below. The ViewModel has a nullable property rating. If it is non-null a handful of controls are rendered to show it graphically and numerically. If it is null however we don’t want to see any of that stuff. This converter helps hide elements of something in the ViewModel is null or empty string.  Continue reading

ExpandoObject Class

It is added to added to .NET 4.0.

Read more HERE.
Represents an object whose members can be dynamically added and removed at run time.

Shortly, ExpandoObject can help you create complex hierarchical objects. For example, imagine that you have a dictionary within a dictionary:

Dictionary<String, object> dict = new Dictionary<string, object>();
Dictionary<String, object> address = new Dictionary<string,object>();
dict["Address"] = address;
address["State"] = "WA";
Console.WriteLine(((Dictionary<string,object>)dict["Address"])["State"]);

The deeper is the hierarchy, the uglier is the code. With ExpandoObject it stays elegant and readable.

dynamic expando = new ExpandoObject();
expando.Address = new ExpandoObject();
expando.Address.State = "WA";
Console.WriteLine(expando.Address.State);

Second, as it was already pointed out, ExpandoObject implements INotifyPropertyChanged interface which gives you more control over properties than a dictionary.

Foreach On IEnumerable

LINK

Background

Let me make few statements as my background for concept.

The IEnumerable<T> interface is a generic interface that provides an abstraction for looping over elements. In addition to providing foreach support, it allows you to use extension methods in the System.Linq namespace.   Continue reading

By Sriramjithendra Posted in C#.NET

Asp.Net Web API VS Asp.Net MVC

  1. Asp.Net MVC is used to create web applications that returns both views and data but Asp.Net Web API is used to create full blown HTTP services with easy and simple way that returns only data not view.
  2. Web API helps to build REST-ful services over the .NET Framework and it also support content-negotiation(it’s about deciding the best response format data that could be acceptable by the client. it could be JSON,XML,ATOM or other formatted data), self hosting which are not in MVC. Continue reading