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

ViewDefinitionChanged event

13 Answers 265 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Catherine
Top achievements
Rank 1
Catherine asked on 01 Mar 2011, 08:08 PM
Hi,

Is
it possible to detect the change of viewDefinition ?

Regards.
C.Léoni.

13 Answers, 1 is accepted

Sort by
0
hwsoderlund
Top achievements
Rank 1
answered on 02 Mar 2011, 11:49 AM
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?
0
Yana
Telerik team
answered on 02 Mar 2011, 03:41 PM
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!
0
hwsoderlund
Top achievements
Rank 1
answered on 02 Mar 2011, 03:59 PM
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
0
Valeri Hristov
Telerik team
answered on 02 Mar 2011, 04:13 PM
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!
0
Valeri Hristov
Telerik team
answered on 02 Mar 2011, 04:14 PM
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!
0
hwsoderlund
Top achievements
Rank 1
answered on 02 Mar 2011, 04:33 PM
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!
0
Valeri Hristov
Telerik team
answered on 02 Mar 2011, 06:07 PM
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!
0
hwsoderlund
Top achievements
Rank 1
answered on 04 Mar 2011, 09:37 AM
You are so right. It has been there all the time. I must have just missed it somehow. Weird... :)
0
Håkan
Top achievements
Rank 1
answered on 18 Jan 2012, 01:55 PM
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

0
Valeri Hristov
Telerik team
answered on 18 Jan 2012, 04:08 PM
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 >>

0
Håkan
Top achievements
Rank 1
answered on 26 Jan 2012, 12:32 PM
Thanks Valerie, that worked!

Regards,
Håkan
0
Lucie
Top achievements
Rank 1
answered on 20 Feb 2012, 12:45 PM
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
0
Yana
Telerik team
answered on 22 Feb 2012, 05:00 PM
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 >>
Tags
ScheduleView
Asked by
Catherine
Top achievements
Rank 1
Answers by
hwsoderlund
Top achievements
Rank 1
Yana
Telerik team
Valeri Hristov
Telerik team
Håkan
Top achievements
Rank 1
Lucie
Top achievements
Rank 1
Share this question
or