EziData Solutions

Web, NET and SQL Server

Getting Started with Starter Kit for Schools

Chris Koenig has just authored a nice little starter kit designed specifically for building a Windows Phone app that displays information about a school.

Once you have downloaded the latest package from github you should extract the zip file, which contains the sample project. Launch Visual Studio and open the MySchoolApp project from the C# folder. Build and run the application to check that everything compiles.

A quick read of the descriptionframe.html instructions located in the description folder is also helpful, as it lays out how to go about changing the default settings.

Most of the data is contained within the app's Data folder, so it's going to be a little painful to update, but certainly it's a good start. A more robust approach would be to create a WFC web service that would feed the relevant data. Having said that, unless your school, college or university changes every other day, the static content will probably suffice.

Adding a new set of links

The app also contains a number of collections of links that can be used to launch the browser and display some online content. Out of the box these are saved in Links.xml and Athletics.xml. It is pretty easy to add more link collections by creating and modifying a copy of these files.

For example you could create Arts.xml to showcase the Arts and Cultural aspects of your school.

This might then contain XML such as shown below:

<links>

  <link>

    <url>http://contosouniversity.net</url>

    <title>Top Arts News</title>

  </link>

  <link>

    <url>http://contosouniversity.net</url>

    <title>Choir News</title>

  </link>

  <link>

    <url>http://contosouniversity.net</url>

    <title>Orchestra News</title>

  </link>

  <link>

    <url>http://contosouniversity.net</url>

    <title>Theatre News</title>

  </link>

</links>

Modify the ViewModel

The next step is to wire up the code so that you can use these links on the MainPage. To do this you need to make a few changes to the MainViewModel.cs file, located in the ViewModels folder.

First create a new property to expose your list of Arts related links

public ObservableCollection<Link> ArtsLinks { get; private set; }

Modify the constructor to instantiate a new instance of this property

this.ArtsLinks = new ObservableCollection<Link>();

Finally, modify the parseLinkFile method and include the code to load the links from Arts.xml.

parseLinkFile("/Data/Arts.xml").ForEach(x => ArtsLinks.Add(x));

Add a new PanoramaItem

To display the new list of Arts links, open MainPage.xaml and copy the existing athletics PanoramaItem. You can then modify this code to point to our newly created ArtsLinks.

<controls:PanoramaItem Header="arts">
    <ListBox x:Name="artsListBox" 
                Margin="0,0,-12,0" 
                ItemsSource="{Binding ArtsLinks}" 
                ItemTemplate="{StaticResource LinkDataTemplate}" 
                SelectionChanged="ListBox_SelectionChanged"/>
</controls:PanoramaItem>

Compile and run the app to see your new Arts links.

Posted: Sep 20 2011, 06:00 by CameronM | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Windows Phone 7 | WP7