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

Show Tooltips on Point, Not Slope

4 Answers 38 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Schley
Top achievements
Rank 1
Schley asked on 01 Feb 2012, 05:28 PM
Is it possible to show a Tooltip for a data series only on the plotted points and not on the slope? I do not want the "closest" point's tooltip to be shown when the mouse hovers on the slope.

4 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 06 Feb 2012, 11:54 AM
Hi Schley,

You can remove the tooltip for the line and make it visible for the PointMarks by retemplating the style for the line:
<UserControl.Resources>
    <Style x:Key="MyLineStyle"
           TargetType="telerik:Line">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:Line">
                    <Canvas x:Name="PART_MainContainer">
                        <telerik:PointMark x:Name="PART_PointMark"
                                           Canvas.Top="{TemplateBinding StartPointY}"
                                           PointMarkCanvasLeft="{TemplateBinding PointMarkCanvasLeft}"
                                           PointMarkCanvasTop="{TemplateBinding PointMarkCanvasTop}"
                                           Visibility="{TemplateBinding PointMarkVisibility}"
                                           ShapeStyle="{TemplateBinding PointMarkShapeStyle}"
                                           Style="{TemplateBinding PointMarkItemStyle}" />
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>

Here's how to apply the Style to the Line Series:
RadChart.DefaultSeriesDefinition = new LineSeriesDefinition()
{
    ItemStyle = this.Resources["MyLineStyle"] as Style,
    ShowItemToolTips = true
};

Kind regards,
Evgenia
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Schley
Top achievements
Rank 1
answered on 06 Feb 2012, 12:51 PM
Is there a way to define the resource in code? I'm using the WPF controls inside an ElementHost and loading resources is a bit of a pain. Thanks!
0
Schley
Top achievements
Rank 1
answered on 06 Feb 2012, 02:19 PM
So here is what I'm trying to do. I've put the above XML into a text file and included it as an embedded resource called "NoTooltipsLineStyle":

<UserControl.Resources>
    <Style x:Key="NoTooltipLineStyle"
           TargetType="telerik:Line">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:Line">
                    <Canvas x:Name="PART_MainContainer">
                        <telerik:PointMark x:Name="PART_PointMark"
                                            Canvas.Top="{TemplateBinding StartPointY}"
                                            PointMarkCanvasLeft="{TemplateBinding PointMarkCanvasLeft}"
                                            PointMarkCanvasTop="{TemplateBinding PointMarkCanvasTop}"
                                            Visibility="{TemplateBinding PointMarkVisibility}"
                                            ShapeStyle="{TemplateBinding PointMarkShapeStyle}"
                                            Style="{TemplateBinding PointMarkItemStyle}" />
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>

Next I'm merging said resource file with the WPF resource dictionary:

static PerfChartControl()
       {
           var wpfApp = WpfApplication.Current;
           
           var resDic = new ResourceDictionary
           {
               {
                   @"NoTooltipLineStyle",
                   Properties.Resources.NoTooltipLineStyle
                   },
           };
 
           wpfApp.Resources.MergedDictionaries.Add(resDic);
           Log.Debug(@"merged resource dictionary with new xaml application");
       }

Then I'm setting the line style:

this.perfChartControl.DefaultSeriesDefinition =
                new LineSeriesDefinition
                {ItemStyle = Resources[@"NoTooltipLineStyle"] as Style,};

All of this code compiles and runs fine, but the desired result is not occurring. For what it is worth I have also removed the UserControl.Resources element from the text I merge so that the Style element is the root node, but this has no effect.
0
Evgenia
Telerik team
answered on 09 Feb 2012, 09:19 AM
Hi Schley,

Why don't you just point your UserControls to the ResourceDictionary object. Here's what I mean:

private void Form1_Load(object sender, EventArgs e)
{
      UserControl1 uc1 = new UserControl1();
      this.elementHost1.Controls.Add(uc1);
 
      uc1.Resources = resDictionary;
}
 
More information on this approach can be found here.

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