DayViewDefinition in behind code

5 posts, 1 answers
  1. Patrick
    Patrick avatar
    31 posts
    Member since:
    Aug 2011

    Posted 21 Nov 2011 Link to this post

    Hi,

    I would like to customize the DayViewDefinition in behind code (VB). When my app start, the information will be get from the database. Now the only way I found to do it...is in XAML...
    <Horaire:DayViewDefinition DayStartTime="06:00"
                              DayEndTime="23:00"    
                               MajorTickLength
    ="1h"    
                               MinorTickLength
    ="5min"    
                               TimerulerMinorTickStringFormat
    =":{0:mm} "                                                                
                               TimerulerMajorTickStringFormat
    ="{}{0:HH}:{0:mm} "    
                               MinTimeRulerExtent
    ="4000"/>

    Thanks for you help.

  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 24 Nov 2011 Link to this post

    Hello Patrick,

    In order to customize the DayViewDefinition in code you have to either give it a x:Name or create it there. For example:

    Public Sub New()
            InitializeComponent()
            Dim dayView As DayViewDefinition
            dayView = New DayViewDefinition
            dayView.DayEndTime = New TimeSpan(6, 0, 0)
            dayView.DayStartTime = New TimeSpan(23, 0, 0)
            dayView.TimerulerMinorTickStringFormat = ":{0:mm}"
        End Sub

    You could find a whole example in this online demo: http://demos.telerik.com/silverlight/#ScheduleView/ScheduleViewConfigurator

    Hope this helps.

    Kind regards,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Patrick
    Patrick avatar
    31 posts
    Member since:
    Aug 2011

    Posted 24 Nov 2011 Link to this post

    Hi Konstantina
    My problem is with 2 differents properties that I can setup in XAML but they are not accessible by code....(See the image)

    - MinorTickLength
    - TimerulerMinorTickStringFormat

    Thanks
  5. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 25 Nov 2011 Link to this post

    Hi Patrick,

    You need to cast the ViewDefinition to the correct one. For example:

    Private Sub scheduleView_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) 
            Dim dayView As DayViewDefinition 
            dayView = TryCast(scheduleView.ViewDefinitions.Item(0), DayViewDefinition) 
            dayView.MajorTickLength = New FixedTickProvider(New DateTimeInterval(5, 0, 0, 0, 0)) 
        End Sub


    Kind regards,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Patrick
    Patrick avatar
    31 posts
    Member since:
    Aug 2011

    Posted 25 Nov 2011 Link to this post

    Hi,

    Thank you very much!!
Back to Top
UI for WPF is Visual Studio 2017 Ready