New to Telerik UI for .NET MAUIStart a free 30-day trial

Represents an IStyleSelector that is used to select the style of the SchedulerBoxView that visualizes the special slot. This style selector enables conditional styling of special time slots based on their properties, such as read-only state, allowing different visual representations for different slot types.

Definition

Namespace:Telerik.Maui.Controls.Scheduler

Assembly:Telerik.Maui.Controls.dll

Syntax:

C#
public class SpecialSlotStyleSelector : IStyleSelector

Inheritance: objectSpecialSlotStyleSelector

Implements: IStyleSelector

Constructors

Initializes a new instance of the SpecialSlotStyleSelector class.

C#
public SpecialSlotStyleSelector()

Properties

Gets or sets the Style of the SchedulerBoxView that visualizes the special slot when in normal state. This style is applied to special slots that are not read-only and represents the default appearance.

C#
public Style NormalStyle { get; set; }
Property Value:

A Style object that defines the appearance of normal special slots.

Example:
csharp
var normalStyle = new Style(typeof(SchedulerBoxView))
{
    Setters =
    {
        new Setter { Property = SchedulerBoxView.ColorProperty, Value = Colors.LightGreen },
        new Setter { Property = SchedulerBoxView.OpacityProperty, Value = 0.4 },
        new Setter { Property = SchedulerBoxView.CornerRadiusProperty, Value = 5 }
    }
};

specialSlotSelector.NormalStyle = normalStyle;

Gets or sets the Style of the SchedulerBoxView that visualizes the special slot when it is read-only. This style is applied to special slots marked as read-only, typically indicating unavailable or restricted time periods.

C#
public Style ReadOnlyStyle { get; set; }
Property Value:

A Style object that defines the appearance of read-only special slots.

Example:
csharp
var readOnlyStyle = new Style(typeof(SchedulerBoxView))
{
    Setters =
    {
        new Setter { Property = SchedulerBoxView.ColorProperty, Value = Colors.Gray },
        new Setter { Property = SchedulerBoxView.OpacityProperty, Value = 0.6 },
        new Setter { Property = SchedulerBoxView.StrokeProperty, Value = Colors.DarkGray },
        new Setter { Property = SchedulerBoxView.StrokeThicknessProperty, Value = 1 }
    }
};

specialSlotSelector.ReadOnlyStyle = readOnlyStyle;

Methods

Override this method to return a specific custom Style. This method is called by the scheduler to determine which style to apply to each special slot based on the slot's properties and state.

C#
public Style SelectStyle(object item, BindableObject bindable)
Parameters:itemobject

The data content representing the slot (SlotNode).

bindableBindableObject

The SchedulerBoxView element to which the style will be applied.

Returns:

Style

An app-specific style to apply, or null if no specific style should be applied.

Implements: IStyleSelector.SelectStyle(object, BindableObject)

Example:
csharp
public class CustomSpecialSlotStyleSelector : SpecialSlotStyleSelector
{
    public Style MaintenanceStyle { get; set; }
    public Style LunchBreakStyle { get; set; }

    public override Style SelectStyle(object item, BindableObject bindable)
    {
        if (item is SlotNode slotNode && bindable is SchedulerBoxView)
        {
            var slot = slotNode.Slot;

            // Check custom slot properties or tags
            if (slot.Data?.ToString() == "Maintenance")
            {
                return MaintenanceStyle;
            }

            if (slot.Data?.ToString() == "Lunch")
            {
                return LunchBreakStyle;
            }

            // Default behavior
            return slot.IsReadOnly ? ReadOnlyStyle : NormalStyle;
        }

        return null;
    }
}