Project layout
Windows Phone SDK does not tell you how to organise your code. Here is a tried and tested skeleton filestructure that can be added to the pre-generated project structure
-
- Converters.cs
-
-
- MyUserControl1.xaml.cs
-
- MyUserControl2.xaml.cs
-
-
- ProfilesPage.xaml.cs
-
- EditProfilePage.xaml.cs
-
- OrdersPage.xaml.cs
-
- EditOrderPage.xaml.cs
-
- Profile.cs
- Order.cs
- DataSourceInterface.cs
- DataSourceInitialiser.cs
- DataSourceMigrater.cs
-
- AppViewModel.cs
-
- AppConstants.cs
-
- App.xaml.cs
View/Model/ViewModel
- See MVVM for People in a Hurry for how to organise code into these directories
SampleData
- Expression Blend can create sample data. That data can go in the SampleData directory
Includes
-
A space for included libraries (
.dll
files) - Pretty much every Silverlight Windows phone project will need the Windows Phone Toolkit (previously part of the 'Silverlight Toolkit', now a separate project)
- Create a separate folder for each library
Images
- A space for images that are included in the project
-
For all images set the following properties in Visual Studio so they are included in the built project,
- Build Type: Content
- Copy to Output Directory: Copy if newer
Root directory
- Classes should be under the root namespace e.g. 'MyAppName'
- AppConstants is a static class with 'const' properties that are used throughout the app
- App.xaml creates an instance of the ViewModel class which can be referred to anywhere in the app as 'App.VM'