Creating The Application
We use SQL Server 2008 as the backend. Our table structure is defined here.
Step 1: Open VS 2012 and create a blank solution, name it as ‘SLN_MetroApps’. In this solution, add a new WCF service, name it as ‘WCF_Sales_Service’. Rename ‘IService1.cs’ to ‘IService.cs’, ‘Service1.svc’ to ‘Service.svc’.
Step 2: We will use Entity Framework for data access. Add a new ADO.NET Entity data model in the WCF service and name it as ‘SalesInfoEDMX’. Complete the wizard and select the above tables. The corresponding entity diagram will be as follows.
Creating Metro Style Client Application
Step 1: To create Metro app, Visual Studio provides multiple templates to get started with. These templates dictate how the applications must be laid out and bound to data. For our single page app scenario, we will pick the Blank App from the Windows Metro Style projects. We call the project ‘SalesInformation’ as below:
Step 2: Open MainPage.Xaml and set up the UI to look as follows
Step 3: Write helper methods to Read all dealers and Products using WCF Service Proxy as below:
Step 4: Write the helper method, to generate ListBox elements. This method will be called when the “+” button is clicked:
Step 5: We instantiate the Products and Orders collections in the Constructor and in the MainPage_Loaded event handler we instantiate the Proxy and call the helper methods to load the data.
Step 6: Call the ‘CreateBillUI’ method on click event of the ‘+’ button
Step 7: Finally on the click event of the ‘Save Invoice’ button write the code for saving the invoice in the database.
Test Run In VS 2012, we can test metro style apps in multiple ways.
We developed a Metro (Windows 8 Style) Business Application. We could definitely reflect the Metro Design Aesthetic better, but as a quick sample, we focused on demonstrating the power of the platform. Metro Styled Apps with their rich design aesthetic are aimed at non-business Consumers. But as we saw, it provides enough flexibility to build functional Business Applications with minimum effort and using existing C# and XAML skills
Download the entire source code