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

Dynamic VisibleDays

5 Answers 103 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Gurpreet
Top achievements
Rank 1
Gurpreet asked on 17 Oct 2012, 03:24 PM
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


5 Answers, 1 is accepted

Sort by
0
Ventzi
Telerik team
answered on 22 Oct 2012, 09:07 AM
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.

0
Gurpreet
Top achievements
Rank 1
answered on 22 Oct 2012, 09:12 AM
Thanks. I've implemented that and it works great!
0
Gurpreet
Top achievements
Rank 1
answered on 24 Oct 2012, 10:38 AM
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}">
0
Vladi
Telerik team
answered on 26 Oct 2012, 08:26 AM
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.

0
Gurpreet
Top achievements
Rank 1
answered on 26 Oct 2012, 08:52 AM
Thanks Vladi,

That works great!
Tags
ScheduleView
Asked by
Gurpreet
Top achievements
Rank 1
Answers by
Ventzi
Telerik team
Gurpreet
Top achievements
Rank 1
Vladi
Telerik team
Share this question
or