Problem with the CustomTimeRulerItemStyleSelector

2 posts, 0 answers
  1. Pierre
    Pierre avatar
    10 posts
    Member since:
    Jul 2011

    Posted 14 May 2012 Link to this post

    Hello,

    I have a big problem with the " CustomTimeRulerItemStyleSelector ". I explain the problem :
    I use a xaml page "Agenda.xaml" associated with a VB page "Agenda.vb". My VB page possess a public class : "Agenda".

    I read the documentation "http://www.telerik.com/help/wpf/radscheduleview-styles-and-templates-styling-timeruleritems.html" several times but I am not come to do what I wanted. I wish I had the same thing as the last photo documentation (http://www.telerik.com/help/wpf/media/timeruler_12.PNG
    )

    I have have copied this code :

    xmlns:local="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.ScheduleView"

    and this code in xaml page:

    <local:CustomTimeRulerItemStyleSelector.MajorTickLineStyle>
        <Style TargetType="scheduleView:TimeRulerLine">
            <Setter Property="BorderBrush" Value="LightCoral" />
            <Setter Property="Background" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="scheduleView:TimeRulerLine">
                        <Border x:Name="LineVisual" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="0 1 0 0"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="Orientation" Value="Horizontal">
                                <Setter TargetName="LineVisual" Property="BorderThickness" Value="1 0 0 0" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </local:CustomTimeRulerItemStyleSelector.MajorTickLineStyle>
     
    <local:CustomTimeRulerItemStyleSelector.MinorTickLineStyle>
        <Style TargetType="scheduleView:TimeRulerLine">
            <Setter Property="BorderBrush" Value="Khaki" />
            <Setter Property="Background" Value="White" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="scheduleView:TimeRulerLine">
                        <Border x:Name="LineVisual" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="0 1 0 0"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="Orientation" Value="Horizontal">
                                <Setter TargetName="LineVisual" Property="BorderThickness" Value="1 0 0 0" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </local:CustomTimeRulerItemStyleSelector.MinorTickLineStyle>

    and this VB code in VB page, following the class "Agenda"

    Public Class CustomTimeRulerItemStyleSelector
     Inherits OrientedTimeRulerItemStyleSelector
     Public Property MinorTickLineStyle() As Style
      Get
       Return m_MinorTickLineStyle
      End Get
      Set
       m_MinorTickLineStyle = Value
      End Set
     End Property
     Private m_MinorTickLineStyle As Style
     Public Property MajorTickLineStyle() As Style
      Get
       Return m_MajorTickLineStyle
      End Get
      Set
       m_MajorTickLineStyle = Value
      End Set
     End Property
     Private m_MajorTickLineStyle As Style
     Public Overrides Function SelectStyle(item As Object, container As DependencyObject, activeViewDeifinition As ViewDefinitionBase) As Style
      If TypeOf container Is TimeRulerLine Then
       Dim tick As TickData = TryCast(item, TickData)
       If tick.Type = TickType.Major Then
        Return MajorTickLineStyle
       End If
       Return MinorTickLineStyle
      End If
      Return MyBase.SelectStyle(item, container, activeViewDeifinition)
     End Function
    End Class

    But I have an error : The MinorTickLineStyle not found on CustomTimeRulerItemStyleSelector.. and I thing that my "local:" not found CustomTimeRulerItemStyleSelector..

    Have you a simle and practical solution ?
    Thanks
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 17 May 2012 Link to this post

    Hi Pierre,

    I've attached a simple example which shows how you can create custom TimeRulerItemsStyleSelector.  It seems that you've used WPF article, the correct one is here.

    Also check the namespaces - in the attached project  "local" refers to Telerik.Windows.Controls while "my" is the namespace of the project.

    Hope this helps.

    Kind regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top