ViewDefinitionChanged event

14 posts, 0 answers
  1. Catherine
    Catherine avatar
    21 posts
    Member since:
    Mar 2009

    Posted 01 Mar 2011 Link to this post

    Hi,

    Is
    it possible to detect the change of viewDefinition ?

    Regards.
    C.Léoni.
  2. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 02 Mar 2011 Link to this post

    There is no such event, but I have used the VisibleRangeChanged event to achieve what I need. Each time the user changes the ViewDefinition, the visible range also changes, so it is pretty much the same. But I agree that ViewDefinitionChanged would be nice to have. @Telerik, perhaps you can add this?
  3. DevCraft banner
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 02 Mar 2011 Link to this post

    Hello Henrik,

    Could you please give us more information about your scenario and why the VisibleRangeChanged event is not suitable? Thanks in advance.


    Kind regards,
    Yana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 02 Mar 2011 Link to this post

    Well, this is not hugely important, but in my app I have a scenario where it would have been useful just from a code-separation point of view. I am displaying a few controls immediately above RadScheduleView where the user can change working hour settings, change his/her working days etc. Some of these should only be available when a certain ViewMode is active. Now, I can accomplish this by listening to the VisibleRangeChanged event and check the ActiveViewDefinitionIndex and then hide/show the controls accordingly, but the code would be a lot cleaner if I could handle that logic inside a ViewDefinitionChanged event instead. As it is now, the VisibleRangeChanged event becomes responsible for doing two things, one of which really has nothing to do at all with the visible range. If I had an event for ActiveViewDefinitionChanged, my code would be cleaner and more maintainable.

    EDIT:
    Also, the way I work around it means that some code has to run unnecessarily each time the visible range is changed, even though the view definition was not changed.

    Best regards,
    /Henrik
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 02 Mar 2011 Link to this post

    A simple workaround (in my opinion, probably the best for the scenario you are describing) is to bind the Visibility of the controls that should be shown depending on the view definition to the ActiveViewDefinition property through a converter...

    Something like this:

    <ComboBox Visibility="{Binding ActiveViewDefinition, ElementName=scheduleView, Converter={StaticResource MonthViewToVisibilityConverter}}" />

    <telerik:RadScheduleView x:Name="scheduleView" ... />

    and in the MonthViewToVisibilityConverter:
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

        return value is MonthViewDefinition;
    }

    Kind regards,
    Valeri Hristov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 02 Mar 2011 Link to this post

    And of course, by:
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

        return value is MonthViewDefinition;
    }

    I ment:
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

        return value is MonthViewDefinition ? Visibility.Visible : Visibility.Collapsed;
    }

    Kind regards,
    Valeri Hristov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  8. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 02 Mar 2011 Link to this post

    That is not a bad idea. Actually, I hadn't noticed that you had added an ActiveViewDefinition property. In the previous pre-beta build there was only ActiveViewDefinitionIndex, which was a bit limited. This should make it easier to hide/show the items I need. Thanks!
  9. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 02 Mar 2011 Link to this post

    Actually the ActiveViewDefinition property has been present from the moment we created RadScheduleView for WPF, in the beginning of the last year and it was always present in RadScheduleView for Silverlight...

    Regards,
    Valeri Hristov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  10. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 04 Mar 2011 Link to this post

    You are so right. It has been there all the time. I must have just missed it somehow. Weird... :)
  11. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 18 Jan 2012 Link to this post

    Hi,

    I have a reason where a ViewChanged event is needed!

    In my ScheduleView I have two TimelineViewDefinitions, with the same date range.
    But I display two different kind och appointments, so I need to load different data when switching between the two views.

    Is there any workaround for this?
    Can I change the template, adding an event to the ViewModeSelection ListBox or something?

    Regards,
    Håkan

  12. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 18 Jan 2012 Link to this post

    Hi Hakan,

    The easiest way to get notifications for the changed view definitions is to bind the ActiveViewDefinition property of RadScheduleView to a property of your view model. When the view definition is changed, the property will also change.

    Greetings,
    Valeri Hristov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  13. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 26 Jan 2012 Link to this post

    Thanks Valerie, that worked!

    Regards,
    Håkan
  14. Lucie
    Lucie avatar
    28 posts
    Member since:
    Jun 2011

    Posted 20 Feb 2012 Link to this post

    in documentation is written
    VisibleRangeChanged - occurs when the view or the Start/End date is changed

    but when I change View type and have WeekViewDefinition and TimeLineViewDefinition with the same start and end day then
     it does not occur.

    I have two buttons in toolbar and I enable/disable them by type of View. I must write two converters and set two bindings.
    It is not to good for future changes in program.

    I think event VisibleRangeChanged should be send in case of change type of view regardless of start and end date or there should
    be separate event for it.

    Regards
  15. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 22 Feb 2012 Link to this post

    Hi Jana,

    This is expected - actually the event is fired when the VisibleRange is changed and in general it changed when the View is switched, that's why we described it like this in the documentation.

    Anyway, your feedback will be considered. We are sorry for the inconvenience.

    All the best,
    Yana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
DevCraft banner