How to dynamically change resources

Hi, can you tell me how to remove and put resources in Scheduler using a comboboxadv

Thanks and regards


3 Replies

SS SaiGanesh Sakthivel Syncfusion Team August 4, 2022 09:20 AM UTC

Hi Jose,


#Regarding adding or removing the resource in the SfScheduler using comboboxadv

Your requirement can be achieved by setting the comboboxadv SelectedItems values to the ResourceCollection property of the SfScheduler. Please refer to the following code snippet for your reference.


Code snippet

<StackPanel FlowDirection="LeftToRight" Grid.Row="0" Orientation="Horizontal">

    <schedule:ComboBoxAdv   Height="40" Width="120" HorizontalAlignment="Left"  VerticalAlignment="Center" Margin="4"

                            ItemsSource="{Binding Resources}"

                            DisplayMemberPath="Name"

                            AllowMultiSelect="True"

                            AllowSelectAll="True"

                            AutoCompleteMode="Suggest"

                            SelectedItems="{Binding SelectedResources}">

    </schedule:ComboBoxAdv>

    <ComboBox x:Name="resourceTypeCombobox" Margin="5" Height="40" Width="120"

                SelectedIndex="2"/>

</StackPanel>

<schedule:SfScheduler x:Name="scheduler"

                        ViewType="TimelineDay"

                        AllowedViewTypes="Day,Week,WorkWeek,TimelineDay,TimelineMonth,TimelineWeek,TimelineWorkWeek"

                        Grid.Row="1"

                        ItemsSource="{Binding Appointments}"

                        ResourceCollection="{Binding SelectedResources}"

                        ResourceGroupType="{Binding ElementName=resourceTypeCombobox,Path=SelectedValue,Mode=TwoWay}"

                        DisplayDate="{Binding CurrentDate}"

                        SelectedDate="{Binding CurrentDate}" >

</schedule:SfScheduler>


In Viewmodel

private void InitialResources()

{

    this.Resources = new ObservableCollection<object>();

    Resources.Add(new SchedulerResource() { Name = "Naveen", Id = "0", Background = Brushes.LightCoral });

    Resources.Add(new SchedulerResource() { Name = "Karthi", Id = "1", Background = Brushes.LightGreen });

    Resources.Add(new SchedulerResource() { Name = "Sai", Id = "2", Background = Brushes.LightSkyBlue });

 

    SelectedResources = new ObservableCollection<object>(Resources);

}


Please refer to the demo sample in the following locations.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SchedulerWPF-143363910


Please let us know if you have any concerns.


Regards,
SaiGanesh Sakthivel



JM Jose Maria August 4, 2022 05:10 PM UTC

Hi,

Thank you very much for your answer

Regards

Jose Maria



SS SaiGanesh Sakthivel Syncfusion Team August 8, 2022 05:25 AM UTC

Hi Jose,


We are glad to know that the provided solution is resolved the query. Please let us know if you need any further assistance on this. 


Regards, 

SaiGanesh Sakthivel


Loader.
Up arrow icon