Dynamic VisibleDays

6 posts, 0 answers
  1. Gurpreet
    Gurpreet avatar
    9 posts
    Member since:
    Oct 2012

    Posted 17 Oct 2012 Link to this post

    Hi,

    I have a ComboBox which contains a list of numbers which reflects the days we would like to see in the RadScheduleView. So I bound the SelectedItem of the ComboBox to the VisibleDays in the TimeLineViewDefinition. The Design view changed straight away and threw the following error 

        '0' is not a valid value for property 'System.Windows.CustomDependencyProperty'

    When I set the value in the xaml it works fine.

    Any idea how this would be done?

    Kind regards,
    Gurpreet


  2. Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 22 Oct 2012 Link to this post

    Hi Gurpreet,

    The VisiblaDays property of the TimeLineViewDefinition accepts only integer numbers bigger than 0. That is why the built-in validation throws the exception.

    If you bind the VisibleDays property of the RadScheduleView to the SelectedItem property of the RadComboBox, you need a ValueConverter to convert the ComboBoxItem to System.Int. This throws an internal binding error and that is why the value is not being validated.

    Hope this helps.

    Greetings,
    Ventzi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Gurpreet
    Gurpreet avatar
    9 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2012 Link to this post

    Thanks. I've implemented that and it works great!
  5. Gurpreet
    Gurpreet avatar
    9 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2012 Link to this post

    I've got another problem with binding.

    When I bind the MinorTickLength and MajorTickLength of my TimeLineView definition and step through the code, the properties are populated correctly. However this is not reflected in the TimeLineView.

    <MinorTickLength="{Binding SelectedMinorTickLength}" MajorTickLength="{Binding SelectedMajorTickLength}">

    The TimeLineView appears the same as when I don't set the MinorTickLength and MajorTickLength in the xaml.

    I saw another post where it was suggested that the bindings be assigned like so:

    <MinorTickLength="{Binding DataContext.SelectedMinorTickLength, ElementName=scheduleViewDetails}">
  6. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 26 Oct 2012 Link to this post

    Hello Gurpreet,

    The MinorTickLength/MajorTickLength properties should be bounded to values of type FixedTickProvider.

    The next code snippets show how the binding should look like:
    In the xaml:
    <telerik:RadScheduleView>
        <telerik:RadScheduleView.ViewDefinitions>
            <telerik:TimelineViewDefinition MinorTickLength="{Binding MinorTickLenght}" MajorTickLength="{Binding MajorTickLenght}" />
        </telerik:RadScheduleView.ViewDefinitions>
    </telerik:RadScheduleView>

    and in the ViewModel:
    public class ViewModel
    {
        public FixedTickProvider MinorTickLenght { get; set; }
        public FixedTickProvider MajorTickLenght { get; set; }
     
        public ViewModel()
        {
            this.MinorTickLenght = new FixedTickProvider(new DateTimeInterval(1, 0, 0, 0));
            this.MajorTickLenght = new FixedTickProvider(new DateTimeInterval(0, 2, 0, 0));
        }
    }

    Hope this helps.

    Greetings,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Gurpreet
    Gurpreet avatar
    9 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Thanks Vladi,

    That works great!
Back to Top
DevCraft banner