Problem when using ResourceTypesSource and SpecialSlotStyleSelector

7 posts, 0 answers
  1. jeya
    jeya avatar
    20 posts
    Member since:
    May 2011

    Posted 03 Aug 2011 Link to this post

    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>
  2. Elneilo
    Elneilo avatar
    6 posts
    Member since:
    Apr 2011

    Posted 03 Aug 2011 Link to this post

    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);


  3. UI for WPF is Visual Studio 2017 Ready
  4. Ed
    Ed avatar
    1 posts
    Member since:
    Aug 2011

    Posted 03 Aug 2011 Link to this post

    Wow, I came here to post the same problem and looks like you guys already have.  A work around / solution would be appreciated!
  5. jeya
    jeya avatar
    20 posts
    Member since:
    May 2011

    Posted 04 Aug 2011 Link to this post

    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..
  6. Elneilo
    Elneilo avatar
    6 posts
    Member since:
    Apr 2011

    Posted 04 Aug 2011 Link to this post

    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?
  7. jeya
    jeya avatar
    20 posts
    Member since:
    May 2011

    Posted 04 Aug 2011 Link to this post

    Hi Elneilo,
    It works with hardcoded GroupDescriptionSource. I just added resoures for the slots of SpecialSlots. Then I got the thing..
  8. praveen
    praveen avatar
    2 posts
    Member since:
    Feb 2015

    Posted 06 Feb 2015 in reply to jeya Link to this post

    Hi please post up updated code i had the same problem
Back to Top
UI for WPF is Visual Studio 2017 Ready