Scheduler for WPF and Silverlight | ComponentOne
WPF Quick Start / Step 1 of 4: Configuring the Data Source
In This Topic
    Step 1 of 4: Configuring the Data Source
    In This Topic

    In this step you will begin by creating a new project in Visual Studio 2010 and configuring the data source.

    To configure the data source in Visual Studio 2010:

    1. Create a new WPF project in Microsoft Visual Studio 2010:
      1. Select File | New Project. The New Project dialog box opens.
      2. Expand the Visual C# node and select NET Framework 3.5. Note that you may have to expand the Other Languages node to find Visual C#.
      3. Choose WPF Application from the list of Templates in the right pane.
      4. Enter a name for your application in the Name field and click OK. A new project is created.
    2. From the Project menu, select Add Page. The Add New Item window appears. Visual C# will be selected under Categories, and Page (WPF) will be selected in the Templates pane.
    3. Leave Page1.xaml in the Name text box and click Add. The new Page1.xaml opens.
    4. If it is not already open, double-click Page1.xaml.cs under the Page1.xaml node in the Solution Explorer to open it.
    5. Add a reference to C1.WPF.Schedule:
      1. Select Project | Add Reference.
      2. Browse to find the location of the C1.WPF.dll and C1.WPF.Schedule assembly files. When Scheduler for Silverlight and WPF is installed, this file is installed to C:\Program Files\ComponentOne\WPF Edition\bin by default. Note that the location may be different if you performed a custom install.
      3. Add the following using statements to the Page1.xaml.cs page:
        Copy Code
        using C1.C1Schedule;
        using MYProjectNAME.ScheduleDataSetTableAdapters;

        Note that the using statement should contain the name of your project in order to work correctly. It will be used to set up the table adapter for your data set. The Imports statement should be used for Visual Basic projects.
    6. Add the data source you are binding to:
      1. Select Data | Add New Data Source. The Data Source Configuration Wizard appears.
      2. Select Database and click Next.
      3. Click the New Connection button and select Microsoft Access DataBase File from the Data Source group box and click Continue.
      4. Click Browse to browse to the Schedule.mdb database installed with Scheduler for Silverlight and WPF. This file was placed in the Common folder during installation.
      5. Click OK in the Add Connection dialog box and then click Next in the Data Source Configuration Wizard dialog box. If you are asked to copy the file to your project, you can click No. The connection is given a name.
      6. Click Next once you create the new connection.
      7. Click Next to save the connection string.
      8. Select the Tables node, leave ScheduleDataSet as the DataSet name, and click Finish.
    7. Add the following C# code to your Page1.xaml.cs Page1 class so it looks like the following. This code will use the data from the dataset to fill the schedule.
      Copy Code
      public partial class Page1 : System.Windows.Controls.Page
               private ScheduleDataSet _schedulerDataSet = null;       
              public Page1()
                   // Use the data set to fill in the data.
              public ScheduleDataSet SchedulerDataSet
                       if (_schedulerDataSet == null)
                           _schedulerDataSet = Resources["dataSet"] as ScheduleDataSet;
                       return _schedulerDataSet;
              private void FillData(ScheduleDataSet ds)
                   if (ds == null)
                   AppointmentsTableAdapter appAd = new AppointmentsTableAdapter();
    8. Save and close the project.