TimeSpanPicker - First Look

4 posts, 0 answers
  1. Joel Palmer
    Joel Palmer avatar
    164 posts
    Member since:
    May 2009

    Posted 09 Mar Link to this post

    I am working through your documentation and am trying to get the 2nd TimeSpanPicker working. 

    <telerik:RadTimeSpanPicker x:Name="Duration"  Value="{Binding SelectedDuration, Mode=TwoWay}"...

    My implementation (different source & different name):

    <telerik:RadTimeSpanPicker
        Grid.Row="1"
        x:Name="Duration" 
        Value="{Binding SelectedDuration, Mode=TwoWay}"
        StringFormat="hh\:mm' hours'"
        TimeSpanWatermarkContent="Select duration...">
        <telerik:RadTimeSpanPicker.TimeSpanComponents>
            <wpf:TimeSpanDurationComponent
                ItemsSource="{Binding Durations, Mode=OneWayToSource}"
                Header="Minutes"/>
        </telerik:RadTimeSpanPicker.TimeSpanComponents>
    </telerik:RadTimeSpanPicker>

    I added the DurationTimeSpanComponent (wpf.TimeSpanDurationComponent) and have the Durations collection on my MV.

    However, I get this error during runtime:

    System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Durations; DataItem=null; target element is 'TimeSpanDurationComponent' (HashCode=46098163); target property is 'ItemsSource' (type 'IEnumerable')

    Your example includes that control is a container.  Is that important? 

    What I see is that you include a namespace that doesn't seem to be part of my install.  When I attempt to set this xmlns I don't have it as an option.  And, when I go to add a reference this is not part listed.  Is the documentation bad?  Is this QuickStart namespace supposed to be part of most common implementations?

    xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=QuickStart.Common"

  2. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 10 Mar Link to this post

    Hi Joel,

    The namespace is not connected with the implementation of the custom TimeSpanComponent. The observed by you error is probably connected to a wrong binding. We have created a sample project that demonstrates how to create the desired TimeSpanComponent and how the ItemsSource should be bound.

    Could you please try to modify it in order to reproduce the observed by you issue and send the project back to us - thus we could be able to provide you with a prompt solution? Providing a code-snippet of your ViewModel will be also of great help.

    We hope this will help you.

    Regards,
    Nasko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joel Palmer
    Joel Palmer avatar
    164 posts
    Member since:
    May 2009

    Posted 10 Mar in reply to Nasko Link to this post

     Your example works and mine does not... even with copy/paste of what you gave me.  I found that my Durations collection never gets called.  Is there a requirement that the TimeSpanDurationComponent be hosted in the same project as the host control?  The binding somehow is not "right" but because it is binding it is almost impossible to debug.
  5. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 11 Mar Link to this post

    Hello Joel,

    There isn't any requirement of placing the custom TimeSpanComponent in the same project as the host control. 

    Could you please, try to reproduce your issue in a sample project and send it back to us? Without being able to reproduce the issue on our side we could not tell for sure what might be the reason for the wrong binding.

    We are looking forward to hearing from you.

    Regards,
    Nasko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top