Scheduler for WPF
クイックスタート

The following quick start guide is intended to get you up and running with Scheduler for WPF. In this quick start you'll create a new Expression Blend project, add Scheduler to your application, bind to a data source, and customize the schedule.

Note: In this quick start guide you will use the C1NWind.mdb database installed by default to  Documents\ComponentOne Samples\Common.

データソースを設定するには

  1. Create a new WPF App in Visual Studio.
  2. Drag and Drop the C1Scheduler control from the toolbox onto the UI Designer Window. The following references automatically get added to the References.
    • C1.WPF.Schedule
    • C1.WPF

    or

    Add the NuGet packages by following these steps:

    1. In the Solution Explorer, right click Dependencies and select Manage NuGet Packages.
    2. In NuGet Package Manager, select nuget.org as the Package source.
    3. Search and select the following package and click Install.
      • C1.WPF.Schedule
  3. In the XAML Editor and add name for the Scheduler control using the following code:
    XAML
    コードのコピー
    <c1:C1Scheduler x:Name="scheduler"></c1:C1Scheduler>
    

Back to Top

Configure the Data Source

  1. In the Solution Explorer, right-click on the project and select Add | New Item.
  2. In the Add New Item dialog, select Data from the installed templates pane, select DataSet from the middle pane and click Add.
  3. From the View menu, select Server Explorer to open it.
  4. Right-click on the DataCollections and select Add Connection.
    WPF App Server Explorer
  5. From the Choose Data Source dialog, select Microsoft Access Database File and click Continue.
    WPF App Choose Data Source Dialog
  6. In the Add Connection dialog, browse and select the C1NWind.mdb file, enter your username and password, and and click the Advanced button available towards the bottom-left.
    WPF App Add Connection Dialog
  7. In the Advanced Properties dialog, navigate to the Provider property and change the Provider to Microsoft.ACE.OLEDB.12.0 and click OK. Observe that a new connection will be added under ServerExplorer | DataConnections.
    WPF App Advanced Properties Dialog
    Note: In case you have a 32-bit system with .NET 4.5.2 API, please select Microsoft.Jet.OLEDB.4.0 as a provider in this step.
  8. In the Solution Explorer, double-click the added DataSet.xsd file, say DataSet1, to open the designer.
  9. Expand the DataConnections | Tables and drag-drop a table, say Appointees, to the designer.
  10. Switch to the code view and add the following using statements:
    C#
    コードのコピー
    using C1.C1Schedule;
    using System.Windows.Controls;
    using ProjectNAME.C1NWindDataSetTableAdapters;
    

    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.

  11. Add the following code to use the data from the dataset to fill the scheduler.
    C#
    コードのコピー
    public partial class MainWindow : Window
    {
        private AppointmentsTableAdapter _appointmentsTableAdapter;
        private AppointeesTableAdapter _appointeesTableAdapter;
        private C1NwindDataSet _dataSet;
    
        public C1NwindDataSet DataSet => _dataSet;
    
        public MainWindow()
        {
            InitializeComponent();
    
            _dataSet = new C1NwindDataSet();
            _appointeesTableAdapter = new AppointeesTableAdapter();
            _appointmentsTableAdapter = new AppointmentsTableAdapter();
            _appointmentsTableAdapter.Fill(_dataSet.Appointments);
            _appointeesTableAdapter.Fill(_dataSet.Appointees);
        }
    }
    

Back to Top

Bind Scheduler to the Data Source

Map the database to the Appointment Storage by adding the following XAML code between the <c1:C1Scheduler></c1:C1Scheduler> tag or adding the following C# code in the MainWindow() constructor:

<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.DataMember" Value="Appointments"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.DataSource" Value="{Binding DataSet, RelativeSource={RelativeSource AncestorType=local:DataSourceBinding, Mode=FindAncestor}}"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.Body.MappingName" Value="Body"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.End.MappingName" Value="End"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.Location.MappingName" Value="Location"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.Start.MappingName" Value="Start"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.Subject.MappingName" Value="Subject"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.AppointmentProperties.MappingName" Value="Properties"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.IdMapping.MappingName" Value="Id"/>
<c1:NestedPropertySetter PropertyName="DataStorage.AppointmentStorage.Mappings.IndexMapping.MappingName" Value="N/A"/>
           
// ContactStorage のマッピングとデータソースを設定します
ContactStorage cstorage = scheduler.DataStorage.ContactStorage;
cstorage.Mappings.IndexMapping.MappingName = "EmployeeID";
cstorage.Mappings.TextMapping.MappingName = "FirstName";
cstorage.DataMember = "Appointees";
cstorage.DataSource = _dataSet.Appointees;

// AppointmentStorage のマッピングとデータソースを設定します
AppointmentStorage storage = scheduler.DataStorage.AppointmentStorage;
storage.Mappings.AppointmentProperties.MappingName = "Properties";
storage.Mappings.Body.MappingName = "Body";
storage.Mappings.End.MappingName = "End";
storage.Mappings.IdMapping.MappingName = "Id";
storage.Mappings.Location.MappingName = "Location";
storage.Mappings.Start.MappingName = "Start";
storage.Mappings.Subject.MappingName = "Subject";
storage.DataMember = "Appointments";
storage.DataSource = _dataSet.Appointments;

DataContext = this;

Back to Top

アプリケーションの実行

これで、スケジュールアプリケーションを作成し、スケジュールをデータソースに連結できたので、最後にアプリケーションを実行してみます。

スケジュールアプリケーションを実行して、Scheduler for WPF の実行時の動作を確認するには

  1. F5]キーを押すか、[デバッグ]メニューから[デバッグの開始]を選択します。スケジュールと[アラーム]ダイアログボックスが表示されます。[すべてのアラームを消す]をクリックします。

  2. 目的の日時の下にある予定の時刻をダブルクリックして予定を設定します。この例では、10月5日火曜日の午前10時に予定を作成します。[予定]ダイアログボックスが開きます。

  3. 件名]に「医者との予定」、[場所]に「病院」、[終了時刻]に「11:00AM」と入力します。
  4. ラベル]の隣にあるドロップダウン矢印をクリックして、[個人用]を選択します。

  5. 保存して閉じる]ボタンをクリックします。スケジュールに新しい予定が表示されます。

Back to Top