Retemplating MonthView background

5 posts, 1 answers
  1. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 23 Aug 2011 Link to this post

    Hi,

    I have modified the ControlTemplate of the MonthView style called "TimeRuleMonthViewItemStyle"
    I made the GoToDay button stretch vertically over the whole area. The content of the button is also replaced by a stackpanel like this:
    <Style x:Key="TimeRulerMonthViewItemStyle" TargetType="local:TimeRulerMonthViewItem">
            <Setter Property="Foreground" Value="{StaticResource MonthViewTimeRulerItemForeground_Normal}" />
            <Setter Property="Margin" Value="0 -1 -1 1" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="local:TimeRulerMonthViewItem">
                        <Grid>
                            <telerik:RadButton VerticalAlignment="Stretch" Padding="0" Style="{StaticResource GoToDayButtonStyle}" Command="local:RadScheduleViewCommands.SetDayViewMode" CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.DateTime.Date}">
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center" IsHitTestVisible="False">
                                    <TextBlock Text="{Binding Content.DateTime.Day, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{StaticResource TextBrush}" Opacity="0.75" HorizontalAlignment="Center" FontSize="24" />
                                    <TextBlock Text="{Binding Content.DateTime, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource DateTimeConverter}, ConverterParameter='MMMM'}" Foreground="{StaticResource TextBrush}" Opacity="0.75" HorizontalAlignment="Center" FontSize="10" Margin="0,-10,0,0" />
                                </StackPanel>
                            </telerik:RadButton>
                        </Grid>              
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    This works fine, but I also use colored backgrounds for saturdays and sundays with special slots.
    And they will not fill the whole area (see attached image).
    I have looked everywhere but can't find what margin or other setting that might cause this.

    Regards,
    Håkan


  2. Pana
    Admin
    Pana avatar
    748 posts

    Posted 25 Aug 2011 Link to this post

    Hi,

    This space is controlled by the Padding property of the bottom level GroupHeader in MonthView. You could create a custom GroupHeader StyleSelector and set the Padding property to have its Top value decreased in MonthView. You could find more information about the StyleSelector here.

    Kind regards,
    Pana
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. DevCraft banner
  4. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 01 Sep 2011 Link to this post

    Hi,

    I tried to change the padding in the MonthViewBottomLevelWeekGroupStyle.
    The default value was "0 -2 0 0". But all that happenened was that all appointments were moved up, but the background color from the special slots remained on the exact same spot as in my previously posted image.

    Regards,
    Håkan
  5. Answer
    Pana
    Admin
    Pana avatar
    748 posts

    Posted 03 Sep 2011 Link to this post

    Hello,

    I am really really sorry. We have designed the GroupHeaders to control the positioning of appointments. We had the intention to make it offset the special slots too but later found some issues I forgot about.

    The easiest way to position the slots would be to create a ScheduleViewStyleSelector similar to the selectors for appointment and GroupHeader styles. When you override the SelectStyle method you will get the view definition. If it is month you should return a custom style if it is not - the default. The custom style should have negative top margin to drag the appointment's top a little bit up.

    Please check the attached project for a style that does so in MonthView. The selector sets only one style for all views though. You can find more resources how to create a custom selector here:
    http://www.telerik.com/help/silverlight/radscheduleview-styles-and-templates-styling-groupheaders.html
    The selector for special slots should work pretty much the way CustomGroupHeaderStyleSelector works. Only it should have conditions like "if (activeViewDeifinition is MonthViewDefinition)" and should return Styles for HighlightItem

    All the best,
    Pana
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 06 Sep 2011 Link to this post

    Works fine now, thanks!

    Regards,
    Håkan
Back to Top
DevCraft banner