4 Answers, 1 is accepted
0
Hi Schley,
You can remove the tooltip for the line and make it visible for the PointMarks by retemplating the style for the line:
Here's how to apply the Style to the Line Series:
Kind regards,
Evgenia
the Telerik team
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":
Next I'm merging said resource file with the WPF resource dictionary:
Then I'm setting the line 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.
<
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
Hi Schley,
Why don't you just point your UserControls to the ResourceDictionary object. Here's what I mean:
More information on this approach can be found here.
All the best,
Evgenia
the Telerik team
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 >>