Pre loader

TooltipTemplate for Annotations

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
0
0

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!

Version
6.2.1.13304
  • You must to post comments
Best Answer
1
0

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

  • You must to post comments
0
0

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>
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies