WPF

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ViewSettingsBase

    Show / Hide Table of Contents

    Class ViewSettingsBase

    Represents a class which is used to configure the properties of all schedule views.

    Inheritance
    System.Object
    ViewSettingsBase
    MonthViewSettings
    TimeSlotViewSettings
    Implements
    System.IDisposable
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.UI.Xaml.Scheduler
    Assembly: Syncfusion.SfScheduler.WPF.dll
    Syntax
    public abstract class ViewSettingsBase : IDisposable

    Constructors

    ViewSettingsBase()

    Declaration
    protected ViewSettingsBase()

    Properties

    AppointmentTemplate

    Gets or sets the appointment template to change the default UI of appointment.

    Declaration
    public DataTemplate AppointmentTemplate { get; set; }
    Property Value
    Type Description
    System.Windows.DataTemplate
    Remarks

    By default, the ScheduleAppointment is set as the DataContext for AppointmentTemplate for both ScheduleAppointment and custom data object in ItemsSource. Custom data object can be bound in AppointmentTemplate by using Data.

    Examples

    The following sample used to configure the custom appointments and appointment template.

    #[Model.cs](#tab/tabid-1)
    public class Meeting
    {
        public string EventName { get; set; }
        public DateTime From { get; set; }
        public DateTime To { get; set; }
        public Brush BackgroundBrush { get; set; }
    }
    #[C#](#tab/tabid-2)
    var customAppointments = new ObservableCollection<Meeting>();
    var meeting = new Meeting()
    {
       EventName = "General Meeting",
        From = new DateTime(2020, 11, 25, 09, 0, 0),
       To = new DateTime(2020, 11, 25, 10, 0, 0),
       BackgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")),
    };
    customAppointments.Add(meeting);
    this.scheduler.ItemsSource = this.CustomAppointments;
    #[Xaml](#tab/tabid-3)
    <Window.Resources>
        <DataTemplate x:Key="appointmentTemplate">
            <StackPanel Background = "{Binding Data.BackgroundBrush}"
                   VerticalAlignment="Stretch"
                   HorizontalAlignment="Stretch">
                <TextBlock
                    Text = "{Binding Data.EventName}"
                    VerticalAlignment="Center"
                    TextTrimming="CharacterEllipsis"
                    TextWrapping="Wrap"
                    TextAlignment="Left"/>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    

    <syncfusion:SfScheduler x:Name="scheduler"> <syncfusion:SfScheduler.DaysViewSettings> <syncfusion:DaysViewSettings AppointmentTemplate = "{StaticResource appointmentTemplate}" /> </ syncfusion:SfScheduler.DaysViewSettings> <syncfusion:SfScheduler.TimelineViewSettings> <syncfusion:TimelineViewSettings AppointmentTemplate = "{StaticResource appointmentTemplate}" /> </ syncfusion:SfScheduler.TimelineViewSettings> <syncfusion:SfScheduler.MonthViewSettings> <syncfusion:MonthViewSettings AppointmentTemplate = "{StaticResource appointmentTemplate}" /> </ syncfusion:SfScheduler.MonthViewSettings> <syncfusion:SfScheduler.AppointmentMapping> <syncfusion:AppointmentMapping Subject = "EventName" StartTime="From" EndTime="To" AppointmentBackground="BackgroundBrush"/> </syncfusion:SfScheduler.AppointmentMapping> </syncfusion:SfScheduler>

    AppointmentTemplateSelector

    Gets or sets the appointment template selectors to change the default UI of appointment based on condition.

    Declaration
    public DataTemplateSelector AppointmentTemplateSelector { get; set; }
    Property Value
    Type Description
    System.Windows.Controls.DataTemplateSelector
    Remarks

    By default, the ScheduleAppointment is set as the DataContext for AppointmentTemplateSelector for both ScheduleAppointment and custom data object in ItemsSource. Custom data object can be bound in AppointmentTemplateSelector by using Data.

    Examples

    The following sample used to configure the custom appointments and appointment template selector.

    #[Model.cs](#tab/tabid-4)
    public class Meeting
    {
        public string EventName { get; set; }
        public DateTime From { get; set; }
        public DateTime To { get; set; }
        public Brush BackgroundBrush { get; set; }
    }
    #[DataTemplateSelector.cs](#tab/tabid-5)
    public class DataTemplateSelectorHelper : DataTemplateSelector
    {
        public DataTemplate AppointmentTemplate { get; set; }
        public DataTemplate AllDayAppointmentTemplate { get; set; }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if ((item as ScheduleAppointment).IsAllDay)
            {
               return AllDayAppointmentTemplate;
            }
            return AppointmentTemplate;
        }
    }
    #[C#](#tab/tabid-6)
    var customAppointments = new ObservableCollection<Meeting>();
    var meeting = new Meeting()
    {
       EventName = "General Meeting",
        From = new DateTime(2020, 11, 25, 09, 0, 0),
       To = new DateTime(2020, 11, 25, 10, 0, 0),
       BackgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFA2C139")),
    };
    customAppointments.Add(meeting);
    this.scheduler.ItemsSource = this.CustomAppointments;
    #[Xaml](#tab/tabid-7)
    <Window.Resources>
        <DataTemplate x:Key="appointmentTemplate">
            <StackPanel Background = "{Binding Data.BackgroundBrush}"
                        VerticalAlignment="Stretch"
                        HorizontalAlignment="Stretch">
                <TextBlock
                    Text = "{Binding Data.EventName}"
                    VerticalAlignment="Center"
                    TextTrimming="CharacterEllipsis"
                    TextWrapping="Wrap"
                    TextAlignment="Left"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="allDayAppointmentTemplate">
            <StackPanel Background = "{Binding Data.BackgroundBrush}"
                        VerticalAlignment="Stretch"
                        HorizontalAlignment="Stretch">
                <TextBlock
                    Text = "{Binding Data.EventName}"
                    VerticalAlignment="Center"
                    TextTrimming="CharacterEllipsis"
                    TextWrapping="Wrap"
                    TextAlignment="Left"/>
            </StackPanel>
        </DataTemplate>
        <local:DataTemplateSelectorHelper x:Key="dataTemplateSelector"
                                          AppointmentTemplate="{StaticResource appointmentTemplate}"
                                          AllDayAppointmentTemplate="{StaticResource allDayAppointmentTemplate}" />
    </Window.Resources>
    

    <syncfusion:SfScheduler x:Name="schedule"> <syncfusion:SfScheduler.DaysViewSettings> <syncfusion:DaysViewSettings AppointmentTemplateSelector="{StaticResource dataTemplateSelector}"/> </ syncfusion:SfScheduler.DaysViewSettings> <syncfusion:SfScheduler.TimelineViewSettings> <syncfusion:TimelineViewSettings AppointmentTemplateSelector="{StaticResource dataTemplateSelector}"/> </ syncfusion:SfScheduler.TimelineViewSettings> <syncfusion:SfScheduler.MonthViewSettings> <syncfusion:MonthViewSettings AppointmentTemplateSelector="{StaticResource dataTemplateSelector}"/> </ syncfusion:SfScheduler.MonthViewSettings> <syncfusion:SfScheduler.AppointmentMapping> <syncfusion:AppointmentMapping Subject = "EventName" StartTime="From" EndTime="To" AppointmentBackground="BackgroundBrush" IsAllDay="IsAllDay"/> </syncfusion:SfScheduler.AppointmentMapping> </syncfusion:SfScheduler>

    ResourceHeaderSize

    Gets or sets the height of resource header in day, week and work week views and width of resource view in timeline views.

    Declaration
    public double ResourceHeaderSize { get; set; }
    Property Value
    Type Description
    System.Double

    ViewHeaderDayFormat

    Gets or sets view header day format.

    Declaration
    public string ViewHeaderDayFormat { get; set; }
    Property Value
    Type Description
    System.String
    Examples

    #C#

    this.Schedule.DaysViewSettings.ViewHeaderDayFormat = "dddd";
    this.Schedule.TimelineViewSettings.ViewHeaderDayFormat = "dddd";
    this.Schedule.MonthViewSettings.ViewHeaderDayFormat = "dddd"

    #Xaml

    <?xml version = "1.0" encoding="utf-8"?>
    <syncfusion:SfScheduler x:Name="Schedule" >
      <syncfusion:SfScheduler.DaysViewSettings>
           <syncfusion:DaysViewSettings ViewHeaderDayFormat = "dddd" />
      </ syncfusion:SfScheduler.DaysViewSettings>
      <syncfusion:SfScheduler.TimelineViewSettings>
           <syncfusion:TimelineViewSettings ViewHeaderDayFormat = "dddd" />
       </ syncfusion:SfScheduler.TimelineViewSettings>
       <syncfusion:SfScheduler.MonthViewSettings>
           <syncfusion:MonthViewSettings ViewHeaderDayFormat = "dddd" />
      </ syncfusion:SfScheduler.MonthViewSettings>
    </syncfusion:SfScheduler>

    ViewHeaderHeight

    Gets or sets a value of view header height.

    Declaration
    public double ViewHeaderHeight { get; set; }
    Property Value
    Type Description
    System.Double

    ViewHeaderTemplate

    Gets or sets the view header template.

    Declaration
    public DataTemplate ViewHeaderTemplate { get; set; }
    Property Value
    Type Description
    System.Windows.DataTemplate
    Examples

    The following sample used to configure the view header template.

    #[Xaml](#tab/tabid-10)
    <syncfusion:SfScheduler x:Name="Schedule">
      <syncfusion:SfScheduler.DaysViewSettings>
           <syncfusion:DaysViewSettings>
               <syncfusion:DaysViewSettings.ViewHeaderTemplate>
                   <DataTemplate>
                       <Grid Margin = "10, 0, 10, 0" >
                           < Grid.RowDefinitions >
                               < RowDefinition Height="*" />
                               <RowDefinition Height = "*" />
                           </ Grid.RowDefinitions >
                           < TextBlock Foreground="Blue" Text="{Binding DayText}" />
                           <TextBlock Grid.Row="1" Text= "{Binding DateText}" />
                       </ Grid >
                   </ DataTemplate >
               </ syncfusion:DaysViewSettings.ViewHeaderTemplate>
           </syncfusion:DaysViewSettings>
       </syncfusion:SfScheduler.DaysViewSettings>
       <syncfusion:SfScheduler.TimelineViewSettings>
       <syncfusion:SfScheduler.TimelineViewSettings>
           <syncfusion:TimelineViewSettings>
               <syncfusion:TimelineViewSettings.ViewHeaderTemplate>
                   <DataTemplate>
                       <Grid Margin = "10, 0, 10, 0" >
                           < Grid.RowDefinitions >
                               < RowDefinition Height= "*" />
                               < RowDefinition Height= "*" />
                           </ Grid.RowDefinitions >
                           < TextBlock Foreground= "Blue" Text= "{Binding DayText}" />
                           < TextBlock Grid.Row= "1" Foreground= "Blue" Text= "{Binding DateText}" />
                       </ Grid >
                   </ DataTemplate >
               </ syncfusion:TimelineViewSettings.ViewHeaderTemplate>
           </syncfusion:TimelineViewSettings>
       </syncfusion:SfScheduler.TimelineViewSettings>
       <syncfusion:SfScheduler.MonthViewSettings>
           <syncfusion:MonthViewSettings>
                <syncfusion:MonthViewSettings.ViewHeaderTemplate>
                    <DataTemplate>
                       <Grid>
                           <TextBlock Foreground = "Red" Text= "{Binding DateText}" />
                       </ Grid >
                   </ DataTemplate >
               </ syncfusion:MonthViewSettings.ViewHeaderTemplate>
           </syncfusion:MonthViewSettings>
       </syncfusion:SfScheduler.MonthViewSettings>
    </syncfusion:SfScheduler>

    VisibleResourceCount

    Gets or sets the resources count to be displayed in schedule view. Defaults to 3 and it will display 3 resource headers in scheduler view port.

    Declaration
    public int VisibleResourceCount { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    Dispose()

    Disposes all the resources used by the ViewSettingsBase class.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Disposes all the resources used by the ViewSettingsBase class.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    Indicates whether the call is from Dispose method or from a System.GC.SuppressFinalize(System.Object).

    Implements

    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved