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

Highlight on Mouse over

1 Answer 341 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 1
Warren asked on 12 Mar 2014, 12:21 PM
I would like to highlight items in my charts when a user moves the mouse over them. For example, placing a border around a bar on a bar series or changing the color of a data point on a line series. When the user moves the mouse off of the item then it would return to it's normal appearance. Does anyone know how I can achieve this?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Mar 2014, 02:25 PM
Hi Warren,

I think the Selection demo from our UI for WPF demos will be helpful for your scenario. You can find it under the RadChartView --> Selection section. 

Basically you can set a PointTemplate on your series and then you can handle the MouseLeave and MouseEnter events on the UIElement placed in the template.
<telerik:BarSeries ItemsSource="{Binding Items}"
                        ValueBinding="Value"
                        CategoryBinding="Category">
    <telerik:BarSeries.PointTemplate>
        <DataTemplate>
            <Border Background="LightCoral"
                    MouseEnter="Border_MouseEnter"
                    MouseLeave="Border_MouseLeave"/>
        </DataTemplate>
    </telerik:BarSeries.PointTemplate>
</telerik:BarSeries>
Here are the handlers:
private void Border_MouseEnter(object sender, MouseEventArgs e)
{
    Border border = sender as Border;
    border.BorderBrush = Brushes.LightSeaGreen;
    border.BorderThickness = new Thickness(5);
}
 
private void Border_MouseLeave(object sender, MouseEventArgs e)
{
    Border border = sender as Border;
    border.BorderBrush = null;
    border.BorderThickness = new Thickness(0);
}

In addition I prepared a sample project which demonstrates this approach.

Please let me know if this fits well in your scenario.

Regards,
Martin
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
Chart
Asked by
Warren
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or