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

Change Point mark Stroke Thickness on mouse over

1 Answer 124 Views
Chart
This is a migrated thread and some comments may be shown as answers.
roni
Top achievements
Rank 1
roni asked on 27 Feb 2011, 09:41 AM
Hi
i am using wpf radchart, i would like to make some effects on the chart point mark when the mouse is over it (for example change its color or change its stroke thickness)
How can i achieve this ?

Thanks 

1 Answer, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 02 Mar 2011, 05:47 PM
Hi roni,

One possible way to achieve the desired is as follows:

1.. Retemplate the pointmark and add MouseLeave and MouseEnter events:
<Style  x:Key="CustomPoint"  TargetType="telerikCharting:PointMark">
    <Setter Property="Size" Value="10" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="telerikCharting:PointMark">
                <Canvas>
                    <Path x:Name="PART_PointMarkPath"
                        Canvas.Left="{TemplateBinding PointMarkCanvasLeft}"
                        Canvas.Top="{TemplateBinding PointMarkCanvasTop}"
                        Style="{TemplateBinding ShapeStyle}"
                        Width="{TemplateBinding Size}"
                        Height="{TemplateBinding Size}"
                            MouseEnter="PART_PointMarkPath_MouseEnter"
                            MouseLeave="PART_PointMarkPath_MouseLeave"
                        Stretch="Fill">
                        <Path.Data>
                            <PathGeometry x:Name="PART_PointMarkPathGeometry" />
                        </Path.Data>
                    </Path>
                </Canvas>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

2. Set the style to the LineSeriesDefinition for examples:
series.Definition = new LineSeriesDefinition();
series.Definition.PointMarkItemStyle = this.Resources["CustomPoint"] as Style;

3. and change the stroke:
private void PART_PointMarkPath_MouseEnter(object sender, MouseEventArgs e)
{
    Path p = e.OriginalSource as Path;
 
    if (p != null)
        p.Stroke = new SolidColorBrush(Colors.Red);
}
 
private void PART_PointMarkPath_MouseLeave(object sender, MouseEventArgs e)
{
    Path p = e.OriginalSource as Path;
 
    if (p != null)
        p.Stroke = new SolidColorBrush(Color.FromArgb(255, 116, 192, 211));
}

I hope this helps.

All the best,
Sia
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!
Tags
Chart
Asked by
roni
Top achievements
Rank 1
Answers by
Sia
Telerik team
Share this question
or