Hello Abdulhameed,
You can achieve your scenario by using behavior, attached to the chart series item. Enabling this attached behavior can be done by using ItemStyle. Here is an example of an attached behavior class:
public static class MouseBehavior
{
public static bool GetIsMouseLeaveAttached(DependencyObject obj)
{
return (bool)obj.GetValue(IsMouseLeaveAttachedProperty);
}
public static void SetIsMouseLeaveAttached(DependencyObject obj, bool value)
{
obj.SetValue(IsMouseLeaveAttachedProperty, value);
}
// Using a DependencyProperty as the backing store for IsMouseLeaveAttached. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsMouseLeaveAttachedProperty =
DependencyProperty.RegisterAttached("IsMouseLeaveAttached", typeof(bool), typeof(BaseChartItem), new PropertyMetadata(OnIsMouseLeaveAttachedChanged));
private static void OnIsMouseLeaveAttachedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
BaseChartItem chartItem = sender as BaseChartItem;
if ((bool)e.NewValue)
{
chartItem.MouseLeave += chartItem_MouseLeave;
}
else
{
chartItem.MouseLeave -= chartItem_MouseLeave;
}
}
static void chartItem_MouseLeave(object sender, MouseEventArgs e)
{
BaseChartItem chartItem = sender as BaseChartItem;
MessageBox.Show(string.Format("Mouse leave Y{0}", chartItem.DataPoint.YValue));
}
}
You can attach this behavior to any class that derives from BaseChartItem. Here is how you can attach it in markup:
I have attached a small demo project that demonstrates this approach. If you have any trouble with it I will be happy to assist you.
Kind regards,
Yavor
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>