Is there a way to create a custom TooltipModifier.TooltipTemplate for Annotations?
I’m trying to find an example of one on the site or in the SciChart examples application but I’m not having any luck. Thanks!
I’d like to be able to pass an object to the tooltip’s metadata like with XySeriesInfo tooltip templates.
Thanks!
- Greg Knox asked 3 years ago
- You must login to post comments
Not with the TooltipModifier no, as this inspects only series.
However, AnnotationBase has a Tooltip property which behaves exactly like a WPF FrameworkElement. You can assign a string, or an object (some UI) there.
Learn more about complex WPF tooltips here:
https://wpf.2000things.com/2011/08/26/373-creating-more-complex-tooltips/
Best regards,
Andrew
- Andrew Burnett-Thompson answered 3 years ago
- You must login to post comments
Here’s how I resolved this for my needs in case anyone else is interested. I’m also open to other recommendations.
VerticalLineAnnotationViewModel’s Tooltip property only accepts strings and there is no Tag or object property to pass a more complex data object so I use LabelValue for one string and Tooltip for another string.
In C#:
VerticalLineAnnotationViewModel verticalLineAnnotation = new VerticalLineAnnotationViewModel() {
LabelValue = myObject.Value1,
Tooltip = myObject.Value2,
// other properties...
};
And then in XAML:
<Style TargetType="sci:VerticalLineAnnotationForMvvm">
<Setter Property="ToolTip">
<Setter.Value>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=LabelValue}" FontWeight="Bold" />
<TextBlock Text="{Binding Path=Tooltip}" />
</StackPanel>
</Setter.Value>
</Setter>
<!-- If Tooltip (Value2) is empty -->
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Tooltip}" Value="">
<Setter Property="ToolTip">
<Setter.Value>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Path=LabelValue}" FontWeight="Bold" />
</StackPanel>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
- Greg Knox answered 3 years ago
- You must login to post comments
Please login first to submit.