綁定的多個DataSeries的自定義RolloverModifierLabel在我更新到SciChart的最新版本之前,我已經有了這個自定義滾動修改器,可以爲我「滾動」的任何給定點顯示多個值。 它實現這樣的:SciChart:爲代碼
<sci:RolloverModifier
DrawVerticalLine="True"
ShowTooltipOn="Always"
SourceMode="AllVisibleSeries"
TooltipLabelTemplate="{StaticResource RolloverLabelTemplate}" />
RolloverLabelTemplate是一個控件模板:
<ControlTemplate
x:Key="RolloverLabelTemplate"
TargetType="sci:TemplatableControl">
<Grid>
...
現在RolloverModifier.TooltipLabelTemplate從API消失了,似乎被TooltipTemplate,這需要一個DataTemplate,不可替代一個ControlTemplate。我試圖使類似的DataTemplate:
<DataTemplate
x:Key="SomeTemplate"
DataType="s:XySeriesInfo">
<Grid>
但是當我嘗試把它分配給RolloverModifier,
<s:RolloverModifier
...
TooltipTemplate="{StaticResource SomeTemplate}" />
我得到以下異常:
無法投類型的對象 'SciChart.Charting.ChartModifiers.RolloverModifier'鍵入 'SciChart.Charting.Visuals.RenderableSeries.BaseRenderableSeries'。
我試圖按照此文件:https://www.scichart.com/documentation/v4.x/webframe.html#RolloverModifier.html
和造型的工具提示模板的話題,它表明有RolloverModifier,但對TooltipTemplate添加到RenderableSeries:
<s:SciChartSurface.RenderableSeries>
<s:FastLineRenderableSeries s:RolloverModifier.TooltipTemplate="{StaticResource XyTooltipTemplate}"/>
</s:SciChartSurface.RenderableSeries>
<s:SciChartSurface.ChartModifier>
<s:ModifierGroup>
<s:RolloverModifier ShowTooltipOn="Always" />
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>
</s:SciChartSurface>
這對我來說是個問題,因爲我沒有在xaml中定義的RenderableSeries。他們被綁定到視圖模型:
<sciVisuals:SciChartSurface
...
SeriesSource="{Binding SciSeries}">
會有多個,其實我甚至不知道有多少。我如何在這種情況下自定義翻轉工具提示標籤?
你先生,是個紳士和學者。 – Shaggydog
有用的信息,但你可以做一些類似的工具提示創建一個DataTemplate(如TooltipTemplate可以讓你做)? – colmde
不,在SciChart v4中,工具提示被移到了系列中,因爲它解決了每個系列工具提示的需求。例如,燭臺系列需要與線條系列不同的模板。如果需要,可以使用WPF的隱式樣式功能將全部模板應用於所有系列:https://wpf.2000things.com/tag/implicit-style/ 創建樣式,TargetType = BaseRenderableSeries,no x:Key ,並將此樣式包含在SciChartSurface.Resources中。試試吧:) –