This is a migrated thread and some comments may be shown as answers.

Problem when using ResourceTypesSource and SpecialSlotStyleSelector

6 Answers 153 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
jeya
Top achievements
Rank 1
jeya asked on 03 Aug 2011, 02:54 PM
Hi,

When I use ResourceTypeSource and SpecialSlotStyleSelctor I dont get the style for the HighlightItem. When I remove the ResourceTypeSource I get the style returned by the specialSlotStyleSelector. I dont know where I made mistake.. Plz Help...

Here is my ScheduleView
<sv:RadScheduleView x:Name="Scheduler" AppointmentsSource="{Binding Appointments}" Loaded="Scheduler_Loaded"
                            MouseLeftButtonUp="Scheduler_MouseLeftButtonUp"  ShowDialog="Scheduler_ShowDialog"
                            ResourceTypesSource="{Binding ResourceTypes}" AppointmentCreating="Scheduler_AppointmentCreating"   >
            <sv:RadScheduleView.ViewDefinitions>
                <sv:DayViewDefinition ShowAllDayArea="True"  MajorTickLength="1h" MinorTickLength="30min"  />
                <sv:WeekViewDefinition ShowAllDayArea="True" MajorTickLength="1h" MinorTickLength="30min" />
                <sv:MonthViewDefinition />
            </sv:RadScheduleView.ViewDefinitions>
            <sv:RadScheduleView.GroupDescriptionsSource>
                <sv:GroupDescriptionCollection>
                    <sv:DateGroupDescription />
                    <sv:ResourceGroupDescription ResourceType="Speaker" />
                </sv:GroupDescriptionCollection>
            </sv:RadScheduleView.GroupDescriptionsSource>
        </sv:RadScheduleView>

And the SpecialSlotStyleSelector...

class SpecialSlotStyleSelector:ScheduleViewStyleSelector
    {
        private Style nonworkingHourStyle;
        public Style NonworkingHourStyle
        {
            get
            {
                return this.nonworkingHourStyle;
            }
            set
            {
                this.nonworkingHourStyle = value;
            }
        }
        public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDefinition)
        {
            return this.NonworkingHourStyle;
        }
 
    }

And here is the style..

<s:SpecialSlotStyleSelector x:Key="SpecialSlotStyleSelector">
                <s:SpecialSlotStyleSelector.NonworkingHourStyle>
                    <Style TargetType="{x:Type sv:HighlightItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Border Background="LightGray" Opacity="0.8" />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </s:SpecialSlotStyleSelector.NonworkingHourStyle>
 
            </s:SpecialSlotStyleSelector>

6 Answers, 1 is accepted

Sort by
0
Elneilo
Top achievements
Rank 1
answered on 04 Aug 2011, 04:27 AM
Hi jeya,

I had the same problem just today and I think I've found the approach that should also work for your situation.
The approach I used was to Bind the GroupDescriptionsSource="{Binding SpeakerDescriptions}" for your example and then remove this hardcoded descriptionssource.

            <sv:RadScheduleView.GroupDescriptionsSource>
                <sv:GroupDescriptionCollection>
                    <sv:DateGroupDescription />
                    <sv:ResourceGroupDescription ResourceType="Speaker" />
                </sv:GroupDescriptionCollection>
            </sv:RadScheduleView.GroupDescriptionsSource>

Then in your view model just set your descriptionsource. (Let me know if this works for you.)

this.SpeakerDescriptions = new ObservableCollection<ResourceGroupDescription>();
ResourceGroupDescription desc = new ResourceGroupDescription();
desc.ResourceType = "Speaker";

this.SpeakerDescriptions.Add(desc);


0
Ed
Top achievements
Rank 1
answered on 04 Aug 2011, 04:43 AM
Wow, I came here to post the same problem and looks like you guys already have.  A work around / solution would be appreciated!
0
jeya
Top achievements
Rank 1
answered on 04 Aug 2011, 06:12 AM
Hi  Elneilo,

Thanks for your reply. I removed the hardcoded GroupDescriptionsSource and bound from the Viewmodel as you suggested. But still I have the problem. I found where I made mistake. I added the resources in specialslots. Now it is working for me..
0
Elneilo
Top achievements
Rank 1
answered on 04 Aug 2011, 07:33 AM
Okay, good to know that it is working now. Please clarify - does it work with hardcoded GroupDescriptionSource? or Does it only work with Binding the GroupDescriptionSource?
0
jeya
Top achievements
Rank 1
answered on 04 Aug 2011, 09:15 AM
Hi Elneilo,
It works with hardcoded GroupDescriptionSource. I just added resoures for the slots of SpecialSlots. Then I got the thing..
0
praveen
Top achievements
Rank 1
answered on 06 Feb 2015, 11:59 AM
Hi please post up updated code i had the same problem
Tags
ScheduleView
Asked by
jeya
Top achievements
Rank 1
Answers by
Elneilo
Top achievements
Rank 1
Ed
Top achievements
Rank 1
jeya
Top achievements
Rank 1
praveen
Top achievements
Rank 1
Share this question
or