Part 1 – Setting up the Projects
In my earlier post here, I introduced the concept of a RowViewModel to make editable grids using the MVVM pattern. In this post, I will demonstrate how to implement the RowViewModel using a combination of IdeaBlade DevForce for the Model, MVVMLite for ViewModel support and Telerik’s Silverlight RadGridView for the View.
- IdeaBlade DevForce 6.0.7 or later.
- Telerik Silverlight Controls 2010.3 or later.
- MVVM Light Toolkit
- VisualStudio 2010 and Silverlight 4
- Silverlight 4 Toolkit
- We’ll use IdeaBlade’s sample database: NorthwindIB. This can be found in the \Program Files\DevForce 2010\ folder.
- I have way too many VS add-ins installed so my screen shots may not appear as your screen does.
- I do use JetBrains Resharper and Telerik’s JustCode, so some of the refactorings and shortcuts may not be available if you do not have these tools.
Creating the Beginning State
- Per the article and sample shown at MVVM Light with DevForce, we will create a sample app using the MVVM Light SL4 template. (I.e. Set up their MvvmLite1 example.)
- Then add the DevForce Silverlight Application project.
- Delete the README_FIRST files.
- In the Model project:
- Delete App.xaml and MainPage.xaml.
- Rename the project with SL suffix. Do not rename the Assembly with the SL suffix and do not change the namespace.
- In the Application project:
- In the Web project:
- Rename the web project to remove the word Model.
- In the project properties:
- Rename the Assembly and the namespace.
- On the Silverlight Applications tab, remove the dead DevForce Silverlight app project (if present).
Add the Silverlight Application (e.g. RVMSample).
- Delete the test HTML page and the Default.aspx page.
- Set the Web project as the Startup Project.
- Set the new test ASPX page as the Start Page.
- Delete the XAP file from the ClientBin folder.
- Save and Close the solution.
- Rename the project folders to match the project names.
- Edit the .SLN file in a text editor to correct the folder names there too.
- Open the solution in VS.
- Build and Run. Nothing so far has changed the functionality so it should work fine:
Creating the Server-Side Model Project
So far so good. We have setup the three-project solution. Unfortunately, this means we’re going to load the EDMX into the Web project, which hardly seems fitting. Let’s create a server-side project to house the server side Model.
- Add a regular Class Library project as the server side Model. This should be named application.Model.
- Delete Class1.
- In the Web project, add a reference to the application.Model project.
- Add an ADO.Net Entity Data Model name it NorthwindIBModel.
- Select to Generate from database.
- Connect to the NorthwindIB database.
- Select the following tables:
- Change the namespace to application.Model.
- Wait while the Entity Manager and IdeaBlade do their code generation. IdeaBlade will also make a link from the Model.SL project to the Model project so they share code.
- Copy the new connectionString settings from app.config in this project to web.config in the web project.
- Build the solution to make sure all the references are configured properly. Run the app. See nothing has changed yet. 🙂
Adding the Grid to the View
Great, now we have client-side (Model.SL) and server-side (Model) model projects, a Silverlight application project and a Web project to host it all in. Let’s go ahead and add the Telerik Grid to the project, then we can finally start looking at the Row-View-Model pattern.
- In the application project, open the MainPage.xaml.
- Change the Width and Height of the page to 1000 x 800.
- Remove the TextBlock that is there.
- Change the <Grid> to a <StackPanel>.
- In the <StackPanel>, drag and drop a Telerik RadGridView from the Toolbox.
- Change the Width and Height of the RadGridView to 1000 x 800.
- Build the solution to make sure all the references are configured properly.
- Run the application. You should see the empty Telerik grid in your browser:
Ta da! All that work to set up the beginning state for exploring RVM. In my next posting, you will get the requirements for the grid and see how we can use the RowViewModel to make in-line grid editing much simpler.
One thought on “Implementing the RowViewModel – Part 1”
[…] Part 1, we setup the projects necessary for a standard business application using IdeaBlade DevForce for […]