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

Problem hiding Major and Minor TimerRulerLines without side effects

5 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rod Yager
Top achievements
Rank 1
Rod Yager asked on 22 Jul 2011, 02:47 PM
I want to hide the major and minor TimeRulerLines. All looks good until you look at the Month and TimeLine view and notice that the major and minor tick lines are not there. Everything looks as desired on the Day and Week view. Here is my code...

taskBoardScheduleView.TimeRulerItemStyleSelector = new CustomTimeRulerItemStyleSelector();
 
public class CustomTimeRulerItemStyleSelector : OrientedTimeRulerItemStyleSelector
    {
        public Style MinorTickLineStyle { get; set; }
        public Style MajorTickLineStyle { get; set; }
 
        public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
        {
            if (container is TimeRulerLine)
            {
                TickData tick = item as TickData;
                if (tick.Type == TickType.Minor || tick.Type == TickType.Major)
                {
                    return Application.Current.FindResource("TransparentTickLineStyle") as Style;
                }
 
                return base.SelectStyle(item, container, activeViewDeifinition);
            }
 
            return base.SelectStyle(item, container, activeViewDeifinition);
        }
    }
 
<Style x:Key="TransparentTickLineStyle" TargetType="{x:Type telerik:TimeRulerLine}">
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="Background" Value="White"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type telerik:TimeRulerLine}">
                    <Border x:Name="LineVisual" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,0" Background="{TemplateBinding Background}"/>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Orientation" Value="Horizontal">
                            <Setter Property="BorderThickness" TargetName="LineVisual" Value="1,0,0,0"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


5 Answers, 1 is accepted

Sort by
0
Dani
Telerik team
answered on 25 Jul 2011, 09:24 AM
Hi Rod ,

Any customizations on the horizontal and vertical lines in RadScheduleView will affect all views. So if you set a transparent border for the time ruler lines in a single style, the style will get applied in DayView, WeekView, MonthView, TimelineView.

If you wish to have a different look of time ruler lines in any of the views, you need to add one more style in your style selector and apply it only when the activeViewDefinition is that particular view. Shortly, modify your selector to include one more conditional statement to check for the activeViewDefinition.

As a side note - if you wanted simply to customize the border brush of the time ruler items, you could do that without having a custom time ruler item style selector. The native OrientedTimeRulerItemStyleSelector does have a HorizontalLineStyle and a VerticalLineStyle which you can modify to change the appearance ot the time ruler lines.

I hope this will be helpful. If you need further help along the way, let me know.

Best wishes,
Dani
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Rod Yager
Top achievements
Rank 1
answered on 25 Jul 2011, 03:01 PM
Actually what I really want is to have the minor TimeRulerLines dissappear but keep the Major lines. Still keeping intact the minor and major tick lines on the ruler. Can you provide an example on how to accomplish that?

Thanks,
Rod


0
Dani
Telerik team
answered on 26 Jul 2011, 03:05 PM
Hello Rod,

Attached is a sample that demonstrates how you can accomplish that behavior - minor tick lines are transparent, while the major tick lines are visible.

All you need is a Selector that provides two separate styles for these two types of ticks.

I hope this will be helpful.

Regards,
Dani
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Rod Yager
Top achievements
Rank 1
answered on 26 Jul 2011, 03:24 PM
Thanks. Is it possible to only show the lines in the view where the days break?
Rod
0
Dani
Telerik team
answered on 27 Jul 2011, 09:09 AM
Hello Rod,

If you referring to having tick lines only at the beginning of each day in TimelineView, you could accomplish that with a slight change in the selector:

public  class TimeRulerItemStyleSelector : OrientedTimeRulerItemStyleSelector
    {
        public Style MinorTickLineStyle { get; set; }
        public Style DayLineStyle { get; set; }
  
        public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
        {           
            if (container is TimeRulerLine)
            {
                TickData tick = item as TickData;
                if (tick.DateTime == tick.DateTime.Date)
                {
                    return DayLineStyle;
                }
                return MinorTickLineStyle;
            }
            return base.SelectStyle(item, container, activeViewDeifinition);
        }
    }

I hope this helps.

Kind regards,
Dani
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
GridView
Asked by
Rod Yager
Top achievements
Rank 1
Answers by
Dani
Telerik team
Rod Yager
Top achievements
Rank 1
Share this question
or