Via MVVM I’m binding an ObservableCollection to my chart. I’m trying to support both a rollover modifier and a tooltip modifier based on a user selection (checkboxes). On the backend I only apply the StyleKey to “TooltipStyle” when one of these checkboxes are selected. I can verify that my model is being updated correctly and that I am able to assign the “StyleKey” to each series in my collection when these values change. However the “tooltips” are never displayed. The rollover works as expected, and I see the tooltip for it, but I can never get the tooltip to display when rollover is unchecked. See anything wrong?
<!-- Modifiers (zoom, panning, tooltips, cursor) -->
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
<s:RubberBandXyZoomModifier IsAnimated="True" IsXAxisOnly="False" />
<s:ZoomExtentsModifier ExecuteOn="MouseDoubleClick" />
<s:ZoomPanModifier ExecuteOn="MouseRightButton" />
<s:MouseWheelZoomModifier ActionType="Zoom" XyDirection="XYDirection" />
<s:XAxisDragModifier DragMode="Scale" />
<s:YAxisDragModifier DragMode="Scale" />
<s:TooltipModifier x:Name="ChartTooltip" IsEnabled="{Binding Path=ShowTooltips}" />
<s:RolloverModifier IsEnabled="{Binding Path=SnapToPoints}" />
<s:CursorModifier x:Name="ChartCursor" IsEnabled="False" ShowAxisLabels="True" Foreground="Red" />
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
My styles are defined below. When I want to see either the tooltips or the rollover I assign the StyleKey to “TooltipStyle” and when neither of them is selected I assign the StyleKey to “NoTooltipStyle”.
<!-- Template for regular tooltips -->
<DataTemplate x:Key="TooltipDataTemplate" DataType="{x:Type s:XySeriesInfo}">
<StackPanel Orientation="Vertical">
<TextBlock Foreground="White">
<Run Text="Distance: " />
<Run Text="{Binding FormattedXValue, Mode=OneTime}" />
<Run Text=" cm" />
</TextBlock>
<TextBlock Foreground="White">
<Run Text="Relative dose: " />
<Run Text="{Binding FormattedYValue, Mode=OneTime}" />
<Run Text=" %" />
</TextBlock>
</StackPanel>
</DataTemplate>
<!-- Hover template for snap -->
<DataTemplate x:Key="SnapDataTemplate" DataType="{x:Type s:XySeriesInfo}">
<StackPanel Orientation="Vertical">
<TextBlock Foreground="White">
<Run Text="Distance: " />
<Run Text="{Binding FormattedXValue, Mode=OneTime}" />
<Run Text=" cm" />
</TextBlock>
<TextBlock Foreground="White">
<Run Text="Relative dose: " />
<Run Text="{Binding FormattedYValue, Mode=OneTime}" />
<Run Text=" %" />
</TextBlock>
</StackPanel>
</DataTemplate>
<!-- Standard series with snap tooltip and regular tooltip -->
<Style TargetType="{x:Type s:FastLineRenderableSeries}" x:Key="TooltipStyle">
<Setter Property="s:TooltipModifier.TooltipTemplate" Value="{StaticResource TooltipDataTemplate}" />
<Setter Property="s:SeriesValueModifier.IncludeSeries" Value="False" />
<Setter Property="s:RolloverModifier.TooltipTemplate" Value="{StaticResource SnapDataTemplate}" />
</Style>
<!-- Standard series with no tooltip -->
<Style TargetType="{x:Type s:FastLineRenderableSeries}" x:Key="NoTooltipStyle">
<Setter Property="s:TooltipModifier.IncludeSeries" Value="False" />
<Setter Property="s:SeriesValueModifier.IncludeSeries" Value="False" />
<Setter Property="s:RolloverModifier.IncludeSeries" Value="False" />
</Style>
- Chris Kirkman asked 5 years ago
- You must login to post comments
Craziest thing. After hours of troubleshooting it was something I would have never thought would cause the problem. My SciChart is actually embedded in a custom usercontrol with it’s own Dependency Properties. Inside the constructor for that control I was setting the “ChartTooltip.IsEnabled = false”. The “ChartTooltip” is the name of my TooltipModifier. Even though the “IsEnabled” property of that modifier is bound to a value in my model that can be either true/false, it didn’t seem to matter that the value was changing. It was as if it just ignored the value to which it was bound simply because I had set it’s value to false on startup. Strange.
- Chris Kirkman answered 5 years ago
- You must login to post comments
Please login first to submit.