Dynamic MajorTickInterval value

8 posts, 0 answers
  1. Ye HaoChen
    Ye HaoChen avatar
    27 posts
    Member since:
    Nov 2009

    Posted 03 Sep 2013 Link to this post

    Hi,

    I need DateTimeCategoricalAxis.MajorTickInterval's value is dynamic.

    For examaple:
    I have a list binding with a LineSeries. the list's count are dynamic.
    When the number of list is extremely small or large, it will be necessary to set the value of MajorTickIntrval dynamic.
    So, the DateTimeCategoricalAxis.MajorTickInterval's value need to changed with List.count.
    like:
    //Count: List's count
    //MajorStepNum: How many labels are there below the X axis.
    MajorTickInterval = Count / MajorStepNum > 1 ? Count / MajorStepNum + 1 : 1;

    But the DateTimeCategoricalAxis.MajorTickInterval can not be Binding.(will thrown an exception)
    So, have other way can be done this? (Except for the assignment MajorTickInterval)

    Thanks
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 06 Sep 2013 Link to this post

    Hi,

    You are absolutely correct, the MajorTickInterval cannot be bound because it is not a dependency property. However you should still be able to achieve the desired effect with code behind.

    Regards,
    Petar Marchev
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ye HaoChen
    Ye HaoChen avatar
    27 posts
    Member since:
    Nov 2009

    Posted 26 Sep 2013 Link to this post

    If it is not a dependency property, will break the MVVM architecture.
    Do you have any way to solve it?

    The Chart in the ListItemTemplate, and MajorTickInterval changes according to the List item data.
    In this situation I don't know how to do.
  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 26 Sep 2013 Link to this post

    Hi Ye HaoChen,

    You can create a new attached property and use it to set the MajorTickInterval:

    public static class ChartUtilities
    {
     public static readonly DependencyProperty MajorTickIntervalProperty = DependencyProperty.RegisterAttached(
     "MajorTickInterval"
     typeof(int),
     typeof(ChartUtilities),
     new PropertyMetadata(null, OnMajorTickIntervalChanged));
     
    public static int GetMajorTickInterval(DependencyObject obj) ....
    public static int Set....
     
    private static void OnDrillDownHelperChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
    {
     var axis = target as DateTimeCategoricalAxis;
     axis.MajorTickInterval = (int)args.NewValue;
     ....

    <telerik:DateTimeCategoricalAxis utilities:ChartSeriesGenerator.MajorTickinterval="{Binding ...}" />

    Regards,
    Petar Marchev
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Ye HaoChen
    Ye HaoChen avatar
    27 posts
    Member since:
    Nov 2009

    Posted 26 Sep 2013 Link to this post

    I would rather appreciate if you could give an example.

    Regards
    Haochen.Ye
  7. Coder
    Coder avatar
    8 posts
    Member since:
    Jan 2014

    Posted 20 Feb 2014 Link to this post

    Could this post please be elaborate on further? Possibly with some example code?

    Thanks.
  8. Valerio
    Valerio avatar
    9 posts
    Member since:
    Sep 2014

    Posted 22 Oct 2014 Link to this post

    Same here, could you post an example or extend/complete the code snippet above?

    Thanks
  9. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 24 Oct 2014 Link to this post

    There you go guys.

    Regards,
    Petar Marchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready