How to update a special region in Timeline View when bound to an ObservableCollection

Hi,

I use the SfScheduler control in Timeline View.
I have set specialregions bound to an ObservableCollection (specialRegions), but when I update a region, no changes appear.


                    <syncfusion:TimelineViewSettings.SpecialTimeRegionTemplate>
                        <DataTemplate>
                            <Border Height="20" Background="{Binding Background}" VerticalAlignment="Bottom" CornerRadius="6" Opacity="1" BorderBrush="Black" BorderThickness="2">
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" x:Name="Paiestack" MouseLeftButtonUp="Paie_MouseLeftButtonUp" >
                                    <TextBlock Text="{Binding Text}" x:Name="infoPaie" Foreground="{Binding Foreground}" HorizontalAlignment="Center" />
                                    <TextBlock Text="{Binding StartTime, StringFormat=\{0:dd/MM/yyyy\}}" x:Name="infoPaieDateTxt" Visibility="Collapsed"></TextBlock>
                                    <TextBlock Text="{Binding ResourceIdCollection[0]}" x:Name="infoPaieIdTxt" Visibility="Collapsed"/>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </syncfusion:TimelineViewSettings.SpecialTimeRegionTemplate>



ObservableCollection<SpecialTimeRegion> specialRegions { get; set; }


        public MainWindow()
        {
            InitializeComponent();
            Schedule.TimelineViewSettings.StartHour = 7;
            Schedule.TimelineViewSettings.EndHour = 18;
            Schedule.DisplayDate =DateTime.Now;


            specialRegions = new ObservableCollection<SpecialTimeRegion> { };
            this.DataContext = this;
        }

        private void infoPaieEnregitrer_Click(object sender, RoutedEventArgs e)
        {
            var region = specialRegions.First(x =>
            x.ResourceIdCollection.Any() &&
            x.ResourceIdCollection[0] == infoPaieID &&
            x.StartTime.ToShortDateString()==infoPaieDate.ToShortDateString()
            );
            region.Text = "OK !";
        }

Could you help me please?

Thanks

Jim


1 Reply

TG Tamilarasan Gunasekaran Syncfusion Team April 2, 2025 07:02 AM UTC

Hi Jim,

# Regarding Updating a special region in Timeline View when bound to an ObservableCollection.

We have reviewed your query and analyzed the provided code snippet. To meet your requirement, you can define the SpecialRegions collection and assign it to the SpecialTimeRegions property in the code-behind, as demonstrated below. For more details about special time regions, please refer to our User Guide documentation.

Schedule.TimelineViewSettings.SpecialTimeRegions = viewModel.SpecialRegions;


We have prepared a sample demonstrating this. Please check the attached sample for your reference. If this solution does not meet your requirements, please don’t hesitate to reach out to us.


We thank you for your support and appreciate your patience.


Regards,
Tamilarasan G.


Attachment: WPFSchedulerSample_(2)_b688e76c.zip

Loader.
Up arrow icon