无法在 silverlight 中加载自定义工具提示
我为线系列图表创建了一个自定义工具提示。 但是我的问题是这个自定义工具提示从未加载。(我仍然得到默认的工具提示,即 X 值)
有什么我应该做的不同的事情吗?
页面.xaml
<Style x:Key="ttip" TargetType="chartingToolkit:LineDataPoint">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:LineDataPoint">
<Grid x:Name="Root" Opacity="0">
<ToolTipService.ToolTip>
<StackPanel>
<ContentControl Content="{TemplateBinding FormattedIndependentValue}"/>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{TemplateBinding FormattedDependentValue}"/>
</StackPanel>
</StackPanel>
</ToolTipService.ToolTip>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<chartingToolkit:Chart x:Name="chart" Grid.Row="0">
<chartingToolkit:LineSeries
DataPointStyle="{StaticResource ttip}" />
page.xaml.cs(创建和绑定)
……
lineSeries = new LineSeries()
{
ItemsSource = storageInfo,
DependentValueBinding = new Binding(dependentValueString),
IndependentValueBinding = new Binding("CollectionDatek__BackingField"),
};
}
感谢
您的帮助……
罗恩..
I have created a custoom tooltip for a lineseries chart. however my problem is that this custom tooltip is never loaded..(I still get the default tooltip i.e. X-value)
Is there something I should be doing differently??
page.xaml
<Style x:Key="ttip" TargetType="chartingToolkit:LineDataPoint">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:LineDataPoint">
<Grid x:Name="Root" Opacity="0">
<ToolTipService.ToolTip>
<StackPanel>
<ContentControl Content="{TemplateBinding FormattedIndependentValue}"/>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{TemplateBinding FormattedDependentValue}"/>
</StackPanel>
</StackPanel>
</ToolTipService.ToolTip>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<chartingToolkit:Chart x:Name="chart" Grid.Row="0">
<chartingToolkit:LineSeries
DataPointStyle="{StaticResource ttip}" />
page.xaml.cs (creating and binding)
...
lineSeries = new LineSeries()
{
ItemsSource = storageInfo,
DependentValueBinding = new Binding(dependentValueString),
IndependentValueBinding = new Binding("CollectionDatek__BackingField"),
};
}
...
Thanks for your help...
Ron..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的示例代码中,您已将模板中网格的不透明度设置为 0。这意味着不可见 - 什么也看不到! 删除该属性,将其设置为 1,或者考虑使用某种情节提要使其正确淡入。
David Anson 的博客文章 "4 个简单的颜色/工具提示" 更改应该会对您有所帮助。 由于您的代码看起来相似,您可能已经有了此参考,但对于其他找到此主题的人来说,这是一个很棒、简洁的文档。
In your example code, you've set the Opacity of the Grid in the template to 0. That means invisible - nothing to see! Either remove the attribute, set it to 1, or consider using some sort of Storyboard to fade it in properly.
David Anson's blog post on "4 simple color/ToolTip" changes should assist you. As your code looks similar, you may already have this reference, but it's a great, concise document for others that find this topic.