<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mubarag&#039;s Blog</title>
	<atom:link href="http://mubarag.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mubarag.wordpress.com</link>
	<description>Share the Known Facts</description>
	<lastBuildDate>Wed, 16 Dec 2009 16:59:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mubarag.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mubarag&#039;s Blog</title>
		<link>http://mubarag.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mubarag.wordpress.com/osd.xml" title="Mubarag&#039;s Blog" />
	<atom:link rel='hub' href='http://mubarag.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Implementing PRISM framework in Silverlight App</title>
		<link>http://mubarag.wordpress.com/2009/12/16/implementing-prism-framework-in-silverlight-app-2/</link>
		<comments>http://mubarag.wordpress.com/2009/12/16/implementing-prism-framework-in-silverlight-app-2/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 16:54:52 +0000</pubDate>
		<dc:creator>mubaragali</dc:creator>
				<category><![CDATA[SilverLight 3.0]]></category>

		<guid isPermaLink="false">http://mubarag.wordpress.com/2009/12/16/implementing-prism-framework-in-silverlight-app-2/</guid>
		<description><![CDATA[Introduction This article describes the implementation of PRISM framework in Silverlight Application with small sample code. Primary we will use this PRISM framework while we are going for composite application. Let&#8217;s see the various scenarios where we could choose composite application. Various Scenarios for implementing composite application Building a composite application that presents information from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mubarag.wordpress.com&amp;blog=10984485&amp;post=15&amp;subd=mubarag&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1 style="color:#000000;margin:24pt 0 0;">Introduction</h1>
<p style="text-align:justify;margin:0 0 10pt;">This article describes the implementation of PRISM framework in Silverlight Application with small sample code. Primary we will use this PRISM framework while we are going for composite application. Let&#8217;s see the various scenarios where we could choose composite application.</p>
<h1 style="margin:24pt 0 0;">Various Scenarios for implementing composite application</h1>
<ul style="margin-top:0;" type="disc">
<li style="margin:0 0 10pt;">Building a composite application that presents information from multiple sources through an integrated user interface.</li>
<li style="margin:0 0 10pt;">When we are developing, testing, and deploying modules independently of the other modules.</li>
<li style="margin:0 0 10pt;">Whenever we able to change the application quickly and safely to meet emergent business requirements.</li>
<li style="margin:0 0 10pt;">Application is being developed by multiple collaborating teams.</li>
<li style="margin:0 0 10pt;">Application targets both WPF and Silverlight, and we want to share as much code as possible between the two platforms.</li>
</ul>
<h1 style="margin:24pt 0 0;">Why we need to use PRISM framework</h1>
<p style="text-align:justify;margin:0 0 10pt;">It helps you to build enterprise-level Windows Presentation Foundation (WPF) and Silverlight client applications. It will help you design and build enterprise-level composite WPF client applications-composite applications use loosely coupled, independently evolvable pieces that work together in the overall application.</p>
<h1 style="margin:24pt 0 0;">M-V-VM Pattern</h1>
<p style="text-align:justify;margin:0 0 10pt;">In the below sample we used Model-View-ViewModel design pattern while we implementing PRISM Framework. This pattern is used only for XAML based technology (WPF, Silverlight). We will small intro of this pattern before moving into actual implementation of PRISM sample.</p>
<p style="text-align:justify;text-indent:-.25in;margin:0 0 10pt 38.25pt;">· View &#8211; it simply represents the UI. In this pattern View does not know the model and of course it is just like dump view to show whatever ViewModel is setting in the data context.</p>
<p style="text-align:justify;text-indent:-.25in;margin:0 0 10pt 38.25pt;">· ViewModel &#8211; ViewModel is the intermediate layer between View and Model. ViewModel simply shapes the data and bind into View. It actually serves the data to view whatever that view is needed.</p>
<p style="text-align:justify;text-indent:-.25in;margin:0 0 10pt 38.25pt;">· Model &#8211; As you know, model is nothing but your service or data access layer which communicates to your database.</p>
<p style="text-align:justify;text-indent:-.25in;margin:0 0 10pt 38.25pt;">· If we want make more decoupled applications, we could implement MVP design pattern in between ViewModel and Model. Now we will implement PRISM samples by having all the above concepts in our mind.</p>
<h1 style="margin:24pt 0 0;">Implementation of PRISM framework</h1>
<p style="text-align:justify;margin:0 0 10pt;">We need to download <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=fa07e1ce-ca3f-4b9b-a21b-e3fa10d013dd&amp;DisplayLang=en" target="_blank">Composite Application Guidance for WPF and Silverlight</a>, from this link, we will get five assemblies and we need to add these dll&#8217;s into our project. First we need to create View and ViewModel for our each module. In this sample, we took one module which is going to show all employee information in grid.</p>
<p style="text-align:justify;margin:0 0 10pt;"><strong>Step : 1 &#8211; Creating View, ViewModel for each module</strong></p>
<p style="text-align:justify;margin:0 0 10pt;">After creating the new Silverlight project,We will get two projects in the solution, one is silverlight project and another one is web application project to host that silverlight application. Just renamed that Silverlight project as Msdngeeks.PrismSamples.Shell. We will use this project later. Now We have to create new Silverlight class library and named as Msdngeeks.PrismSamples.Modules. Now, We have to add one view for showing all the employee information, so we added one usercontrol(xaml file) into this project and two class files named as EmployeeModule.cs and ShowAllEmployeesViewModel.cs.</p>
<ol style="margin-top:0;" type="1">
<li style="text-align:justify;margin:0 0 10pt;"><strong>ShowAllEmployeesView.xaml</strong> (View) looks as below after adding one datagrid in the usercontrol.</li>
</ol>
<p style="text-align:justify;margin:0 0 10pt;">Xaml code:</p>
<p style="line-height:normal;margin:0;">&lt;UserControl x:Class=&#8221;Msdngeeks.PrismSamples.Modules.ShowAllEmployeesView&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns=&#8221;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns:data=&#8221;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns:x=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8221;</p>
<p style="line-height:normal;margin:0;">Width=&#8221;400&#8243; Height=&#8221;300&#8243;&gt;</p>
<p style="line-height:normal;margin:0;">&lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;White&#8221;&gt;</p>
<p style="line-height:normal;margin:0;">&lt;data:DataGrid x:Name=&#8221;SearchResultGrid&#8221; Grid.Row=&#8221;1&#8243; Background=&#8221;#FF8BAFE6&#8243; IsReadOnly=&#8221;True&#8221; BorderThickness=&#8221;1&#8243; ItemsSource=&#8221;{Binding Employees}&#8221; BorderBrush=&#8221;Black&#8221;&gt;</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">&lt;/data:DataGrid&gt;</p>
<p style="line-height:normal;margin:0;">&lt;/Grid&gt;</p>
<p style="text-align:justify;margin:0 0 10pt;">&lt;/UserControl&gt;</p>
<p style="text-align:justify;margin:0 0 10pt;"><strong>ShowAllEmployeesView.xaml.cs</strong></p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Modules</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public partial class ShowAllEmployeesView : UserControl</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public ShowAllEmployeesView(ShowAllEmployeesViewModel ViewModel)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">InitializeComponent();</p>
<p style="line-height:normal;margin:0;">this.DataContext = ViewModel;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">In above cs file, ViewModel class object is passed as parameter to set the datacontext in the view. So for we have created View for showing employee information, now we are going to create one ViewModel which shapes the data for the view.</p>
<ol start="2" style="margin-top:0;" type="1">
<li style="text-align:justify;margin:0 0 10pt;">ShowAllEmployeesViewModel.cs (ViewModel) looks as below code,</li>
</ol>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Modules</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class ShowAllEmployeesViewModel</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">IEmployeeService employeeService;</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">public ShowAllEmployeesViewModel(IEmployeeService employeeService)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">Employees = new ObservableCollection&lt;EmployeeDTO&gt;();</p>
<p style="line-height:normal;margin:0;">this.employeeService = employeeService;</p>
<p style="line-height:normal;margin:0;">this.employeeService.ShowEmployee(OnSearchComplete);</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">private void OnSearchComplete(IEnumerable&lt;EmployeeDTO&gt; newEmployees)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">this.Employees.Clear();</p>
<p style="line-height:normal;margin:0;">foreach (var employee in newEmployees)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">this.Employees.Add(employee);</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">public ObservableCollection&lt;EmployeeDTO&gt; Employees</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">get;</p>
<p style="line-height:normal;margin:0;">private set;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">In the above code, we are adding each employee information into observable collection Employees property in the OnSearchComplete method. We are invoking the service method ShowEmployee() in the constructor of view model class to get all employee information. In the above code, am using EmployeeDTO class which is used as contract class. Since we are using WCF REST Service, we are using this common contract class for both client and service.</p>
<p style="text-align:justify;margin:0 0 10pt;">Our contract class is in another project named as Msdngeeks.PrismSamples.Contracts and its having one contract class named as EmployeeDTO.cs. The code for this contract class is as follows,</p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Contracts</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class EmployeeDTO</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public int EmpId { get; set; }</p>
<p style="line-height:normal;margin:0;">public string EmpName { get; set; }</p>
<p style="line-height:normal;margin:0;">public DateTime DOB { get; set; }</p>
<p style="line-height:normal;margin:0;">public string Designation { get; set; }</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<ol start="3" style="margin-top:0;" type="1">
<li style="text-align:justify;margin:0 0 10pt;">EmployeeModule.cs (Module Class) Each module should have separate module class which helps to register the module in the container using unity framework. The code looks as below,</li>
</ol>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Modules</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class EmployeeModule :IModule</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">private IRegionManager regionManager;</p>
<p style="line-height:normal;margin:0;">private IUnityContainer container;</p>
<p style="line-height:normal;margin:0;">public EmployeeModule(IRegionManager regionManager, IUnityContainer container)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">this.regionManager = regionManager;</p>
<p style="line-height:normal;margin:0;">this.container = container;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">#region IModule Members</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">public void Initialize()</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">this.container.RegisterType&lt;IEmployeeService, EmployeeService&gt;(new ContainerControlledLifetimeManager());</p>
<p style="line-height:normal;margin:0;">this.regionManager.RegisterViewWithRegion(&#8220;ResultsRegion&#8221;, typeof(ShowAllEmployeesView));</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">#endregion</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt .25in;">In the above code, we are inheriting IModule interface from the composite framework which we added earlier as reference (download dll). In the initialize method, we are registering the type of our service class to the container and also we are registering the region manager with the type of our view class name ShowAllEmployeesView.</p>
<p style="text-align:justify;margin:0 0 10pt .25in;"><strong>Step 2:</strong> Creating Model using Entity Framework and REST Service</p>
<p style="text-align:justify;margin:0 0 10pt .25in;">Now we need to create one model, So, We have taken Entity Framework as model for this sample. We have created one WCF REST Service to get all the employee information from db and this service is hosted in IIS Web server. These things are done in separate solution file which is having entity framework and WCF Service as well as the common contract class in separate projects.</p>
<p style="text-align:justify;margin:0 0 10pt .25in;">Entity Framework Model is as follows,</p>
<p style="text-align:justify;margin:0 0 10pt .25in;">
<p style="text-align:justify;margin:0 0 10pt;">Our table Employee_Profile has four fields as above. Now we need service to get all the employee information. Our WCF REST Service is as follows,</p>
<p style="text-align:justify;margin:0 0 10pt;"><strong>WCF Service Interface Code:</strong></p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.WCFService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">[ServiceContract]</p>
<p style="line-height:normal;margin:0;">public interface IRestService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">[OperationContract(Name = "GetEmployee")]</p>
<p style="line-height:normal;margin:0;">[WebGet(UriTemplate = "/",ResponseFormat=WebMessageFormat.Json)]</p>
<p style="line-height:normal;margin:0;">List&lt;EmployeeDTO&gt; GetEmployee();</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt;"><strong>Service Class Code:</strong></p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.WCFService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class Service1 : IRestService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">#region IRestService Members</p>
<p style="line-height:normal;margin:0;">public List&lt;EmployeeDTO&gt; GetEmployee()</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">EmployeeEntities dataContext = new EmployeeEntities();</p>
<p style="line-height:normal;margin:0;">var emp = (from p in dataContext.Employee_Profile</p>
<p style="line-height:normal;margin:0;">select p);</p>
<p style="line-height:normal;margin:0;">List&lt;EmployeeDTO&gt; emplist = emp.ToList().ConvertAll(new Converter&lt;Employee_Profile, EmployeeDTO&gt;(Converter.ConvertEmployeeToEmployeeDTO));</p>
<p style="line-height:normal;margin:0;">return emplist;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">#endregion</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">We used one converter class to convert our employee class type to our contract class EmployeeDTO Type. Converter class code is as follows,</p>
<p style="text-align:justify;margin:0 0 10pt;"><strong>Converter.cs</strong></p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.WCFService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class Converter</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public static EmployeeDTO ConvertEmployeeToEmployeeDTO(Employee_Profile value)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">EmployeeDTO emp = new EmployeeDTO();</p>
<p style="line-height:normal;margin:0;">emp.EmpId = value.EmpId;</p>
<p style="line-height:normal;margin:0;">emp.EmpName = value.EmpName;</p>
<p style="line-height:normal;margin:0;">emp.DOB = value.DOB;</p>
<p style="line-height:normal;margin:0;">emp.Designation = value.Designation;</p>
<p style="line-height:normal;margin:0;">return emp;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">These are all the service side code and this service is hosted in IIS Web Server. I think explaining the above code is out of the scope for this article. Just I gave all the code which I used to retrieve all the employee information using entity framework and WCF.</p>
<p style="text-align:justify;margin:0 0 10pt;">Now we will see how to call this service in our employee service class.</p>
<ol style="margin-top:0;" type="1">
<li style="text-align:justify;margin:0 0 10pt;">We need to create new silverlight class library project and named as Msdngeeks.PrismSamples.Services.</li>
<li style="text-align:justify;margin:0 0 10pt;">Then add one interface in the name of IEmployeeService.cs and one class in the name of EmployeeService.cs for the service.</li>
</ol>
<p style="text-align:justify;margin:0 0 10pt;"><strong>IEmployeeService.cs</strong> is as follows,</p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Services</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public interface IEmployeeService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">void ShowEmployee(Action&lt;IEnumerable&lt;EmployeeDTO&gt;&gt; SearchCompleteCallback);</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt .5in;">In the above code, we created one interface which is having one method declaration ShowEmployee.</p>
<p style="text-align:justify;margin:0 0 10pt .5in;">
<p style="margin:0 0 10pt;"><strong>EmployeeService.cs</strong> class is as follows,</p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Services</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class EmployeeService:IEmployeeService</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">List&lt;EmployeeDTO&gt; res;</p>
<p style="line-height:normal;margin:0;">#region IEmployeeService Members</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">public void ShowEmployee(Action&lt;IEnumerable&lt;Msdngeeks.PrismSamples.Contracts.EmployeeDTO&gt;&gt; SearchCompleteCallback)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">string uri = &#8220;http://localhost/PRISMSampleService/RestService.svc/&#8221;;</p>
<p style="line-height:normal;margin:0;">WebClient wc = new WebClient();</p>
<p style="line-height:normal;margin:0;">wc.DownloadStringCompleted += (sender, e) =&gt; SearchCompleteCallback(GetEmployees(e));</p>
<p style="line-height:normal;margin:0;">wc.DownloadStringAsync(new Uri(uri));</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">#endregion</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">private IEnumerable&lt;EmployeeDTO&gt; GetEmployees(DownloadStringCompletedEventArgs e)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">string xml = e.Result;</p>
<p style="line-height:normal;margin:0;">DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(List&lt;EmployeeDTO&gt;));</p>
<p style="line-height:normal;margin:0;">MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(xml));</p>
<p style="line-height:normal;margin:0;">res = (List&lt;EmployeeDTO&gt;)json.ReadObject(ms);</p>
<p style="line-height:normal;margin:0;">return res;</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="margin:0 0 10pt;">}</p>
<p style="text-align:justify;margin:0 0 10pt;">In the above code, we calling the WCF REST Service using the above uri in ShowEmployee mthod. When the download string completed event is triggered then it comes to GetEmployees method. In this method we have to de serialize the data which is coming as Json serializable data from the service. Finally it returns the list of employee information to view model.</p>
<p style="margin:0 0 10pt;"><strong>Step 3: Creating Bootstrapper and Shell Class</strong></p>
<p style="margin:0 0 10pt;">So for we have created View, ViewModel, Model (Service) classes. Now we have to add one Boot strapper class in the Msdngeeks.PrismSamples.Shell project which we created earlier.</p>
<p style="margin:0 0 10pt;">The <strong>Bootstrappe</strong>r class file is as follows,</p>
<p style="line-height:normal;margin:0;">namespace Msdngeeks.PrismSamples.Shell</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">public class Bootstrapper:UnityBootstrapper</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">protected override DependencyObject CreateShell()</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">Shell shell = new Shell();</p>
<p style="line-height:normal;margin:0;">Application.Current.RootVisual = shell;</p>
<p style="line-height:normal;margin:0;">return shell;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">protected override Microsoft.Practices.Composite.Modularity.IModuleCatalog GetModuleCatalog()</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">ModuleCatalog catalog = new ModuleCatalog();</p>
<p style="line-height:normal;margin:0;">catalog.AddModule(typeof(EmployeeModule));</p>
<p style="line-height:normal;margin:0;">return catalog;</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="line-height:normal;margin:0;">}</p>
<p style="margin:0 0 10pt;">}</p>
<p style="margin:0 0 10pt;">In the above code, we inherited UnityBootstrapper class from the composite framework which added reference earlier into this project. In the CreateShell method, we are setting the shell as current application and return the shell. In the GetModuleCatelog method, we need to all the module which we are having in the project. Currently we are having only one module, so we added one employee module into catalog.</p>
<p style="margin:0 0 10pt;">In <strong>Shell.xaml</strong> class looks as below after adding regions and tab controls to display all the views which we created in the module project,</p>
<p style="line-height:normal;margin:0;">&lt;UserControl x:Class=&#8221;Msdngeeks.PrismSamples.Shell.Shell&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns=&#8221;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns:controls=&#8221;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns:x=&#8221;http://schemas.microsoft.com/winfx/2006/xaml&#8221;</p>
<p style="line-height:normal;margin:0;">xmlns:Regions=&#8221;clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation&#8221;</p>
<p style="line-height:normal;margin:0;">Width=&#8221;400&#8243; Height=&#8221;300&#8243;&gt;</p>
<p style="line-height:normal;margin:0;">&lt;Grid x:Name=&#8221;LayoutRoot&#8221; Background=&#8221;Blue&#8221;&gt;</p>
<p style="line-height:normal;margin:0;">&lt;Grid.RowDefinitions&gt;</p>
<p style="line-height:normal;margin:0;">&lt;RowDefinition Height=&#8221;auto&#8221;/&gt;</p>
<p style="line-height:normal;margin:0;">&lt;RowDefinition Height=&#8221;*&#8221;/&gt;</p>
<p style="line-height:normal;margin:0;">&lt;/Grid.RowDefinitions&gt;</p>
<p style="line-height:normal;margin:0;">&lt;ContentControl Regions:RegionManager.RegionName=&#8221;EmployeeSearchRegion&#8221; Grid.Row=&#8221;0&#8243; Margin=&#8221;2&#8243;/&gt;</p>
<p style="line-height:normal;margin:0;">&lt;controls:TabControl Grid.Row=&#8221;1&#8243; Margin=&#8221;3&#8243; Regions:RegionManager.RegionName=&#8221;ResultsRegion&#8221;&gt;&lt;/controls:TabControl&gt;</p>
<p style="line-height:normal;margin:0;">
<p style="line-height:normal;margin:0;">&lt;/Grid&gt;</p>
<p style="line-height:normal;margin:0;">&lt;/UserControl&gt;</p>
<p style="margin:0 0 10pt;">
<p style="margin:0 0 10pt;">In the above code, highlighted region name and the region name which is highlighted in the module class, say EmployeeModul.cs file in the Module project should be same.</p>
<p style="margin:0 0 10pt;">Last but not least, we need to add bootstrapper class in the Application_Statup method in the app.xaml.cs file, it looks as below after adding the bootstrapper class,</p>
<p style="line-height:normal;margin:0;">private void Application_Startup(object sender, StartupEventArgs e)</p>
<p style="line-height:normal;margin:0;">{</p>
<p style="line-height:normal;margin:0;">new Bootstrapper().Run();</p>
<p style="margin:0 0 10pt;">}</p>
<p style="margin:0 0 10pt;"><strong>Note:</strong> Add Microsoft Composite DLL&#8217;s in all the projects which we created except contracts project.</p>
<p style="margin:0 0 10pt;">Now we can press f5 to run the application. We will see event handling in the future article using PRISM Framework. Click here to download Source Code</p>
<h1 style="margin:24pt 0 0;">Conclusion</h1>
<p style="margin:0 0 10pt;">In this article, I have discussed about the overview of PRISM framework with small sample. We will see remaining features of PRISM framework in the future articles.</p>
<p style="margin:0 0 10pt;">
<p style="margin:0 0 10pt;">
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mubarag.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mubarag.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mubarag.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mubarag.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mubarag.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mubarag.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mubarag.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mubarag.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mubarag.wordpress.com&amp;blog=10984485&amp;post=15&amp;subd=mubarag&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mubarag.wordpress.com/2009/12/16/implementing-prism-framework-in-silverlight-app-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/322815ced509b63315e72c52e44c4b63?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mubarag</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://mubarag.wordpress.com/2009/12/16/hello-world/</link>
		<comments>http://mubarag.wordpress.com/2009/12/16/hello-world/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:01:04 +0000</pubDate>
		<dc:creator>mubaragali</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mubarag.wordpress.com&amp;blog=10984485&amp;post=1&amp;subd=mubarag&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to <a href="http://wordpress.com/">WordPress.com</a>. This is your first post. Edit or delete it and start blogging!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mubarag.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mubarag.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mubarag.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mubarag.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mubarag.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mubarag.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mubarag.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mubarag.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mubarag.wordpress.com&amp;blog=10984485&amp;post=1&amp;subd=mubarag&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mubarag.wordpress.com/2009/12/16/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/322815ced509b63315e72c52e44c4b63?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mubarag</media:title>
		</media:content>
	</item>
	</channel>
</rss>
