Hi
Richard,
What I can suggest you would to implement a custom attached property that will be hooking to the event and executing a custom command in the ViewModel. So the attached property should be defined the following way:
public
class
GanttHelper
{
static
RadGanttView myGantt;
public
static
bool
GetIsEnabled(DependencyObject obj)
{
return
(
bool
)obj.GetValue(IsEnabledProperty);
}
public
static
void
SetIsEnabled(DependencyObject obj,
bool
value)
{
obj.SetValue(IsEnabledProperty, value);
}
// Using a DependencyProperty as the backing store for IsEnabled. This enables animation, styling, binding, etc...
public
static
readonly
DependencyProperty IsEnabledProperty =
DependencyProperty.RegisterAttached(
"IsEnabled"
,
typeof
(
bool
),
typeof
(GanttHelper),
new
PropertyMetadata(OnIsEnabledChanged));
private
static
void
OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if
(e.NewValue != e.OldValue)
{
myGantt = d
as
RadGanttView;
myGantt.ExpandCollapseService.HierarchicalCollectionAdapter.CollectionChanged -= HierarchicalCollectionAdapter_CollectionChanged;
myGantt.ExpandCollapseService.HierarchicalCollectionAdapter.CollectionChanged += HierarchicalCollectionAdapter_CollectionChanged;
}
}
static
void
HierarchicalCollectionAdapter_CollectionChanged(
object
sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
(myGantt.DataContext
as
ViewModel).CustomCommand.Execute(e.NewItems);
}
}
Enable the helper the following way:
After the event is fire the CustomCommand from the ViewModel will be executed with the new items as a parameter.
Hope this helps.
Regards,
Kalin
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.