Scheduler for WPF | ComponentOne
Appointments / Categories / Add Categories to the Categories List
In This Topic
    Add Categories to the Categories List
    In This Topic

    Scheduler supports categories created at run time through the Categories dialog box. Once added to the list, the category can be assigned to an appointment.

    The new categories appears in the Categories dialog box when the Categories button is clicked in the Appointment dialog box:

    Category dialog in WPF Scheduler

    To add a category at run time:

    1. Add a new or open an existing appointment.
    2. Click the Categories button in the Appointment dialog box. The Categories dialog box appears.
    3. Enter a name in the Available text box and click Add. The new category is added at the end of the list.
    4. Click Ok to close the Categories dialog box.

    To add a categories programmatically, use the following code:

    C#
    Copy Code
    ObservableCollection<string> categories = new ObservableCollection<string>();
    
    // Add categories to the category list
    private void Add_Categories(object sender, RoutedEventArgs e)
    {
        // add new categories to the existing list
        categories.Add("Conference");
        categories.Add("Video Call");
        categories.Add("Interview");
        categories.Add("Games");
    
        foreach (string category in categories)
        {
            Category ct = new Category();
            ct.MenuCaption = category;
            if (!sched1.DataStorage.CategoryStorage.Categories.Any(x => x.MenuCaption == category))
                sched1.DataStorage.CategoryStorage.Categories.Add(ct);
        }
    }