Silverlight 工具包图表:将超链接分配给轴
我有一个简单的 Silverlight Toolkit 图表,它绑定到以下类型的集合:
public class ChartItemClass
{
public string Name { get; set; }
public double Value { get; set; }
public string Url { get; set; }
}
我可以获得一个图表来正确显示名称(X 轴)和值(Y 轴),但我想要 X 上的标签-axis 是 Url 属性的 HyperlinkButtons。 X 轴标签应该类似于以下内容:
<HyperlinkButton Content="*Name Property Here*" NavigateUri="*Url Property Here*" TargetName="_blank"></HyperlinkButton>
我找到了一个示例,它允许我为 X 轴设置 AxisLabelStyle,因此标签现在是 HyperlinkButton。问题是我无法将 Url 属性分配/绑定为 NavigateUri。有什么想法吗?
I have a simple Silverlight Toolkit Chart which is bound to a collection of the following type:
public class ChartItemClass
{
public string Name { get; set; }
public double Value { get; set; }
public string Url { get; set; }
}
I can get a Chart to display the Name (X-axis) and Value (Y-axis) correctly, but I would like the labels on the X-axis to be HyperlinkButtons to the Url property. The X-axis label should be something like the following:
<HyperlinkButton Content="*Name Property Here*" NavigateUri="*Url Property Here*" TargetName="_blank"></HyperlinkButton>
I found an example which allowed me to set the AxisLabelStyle for the X-axis so the Labels are now HyperlinkButtons. The problem is I haven't been able to assign/bind the Url property as the NavigateUri. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先我将发布完整的代码,然后是解释。
诀窍在于这一行:
使用此绑定,您可以将整个对象传递到独立轴,而不仅仅是一个属性。
之后,您可以在标签的控件模板中获取绑定对象的属性:
Binding
关键字而不是TemplateBinding
看起来很奇怪,但它是允许的并且有效。还有一点需要注意:
Url
属性必须包含http
前缀。它不适用于www
。At first I will post the complete code and after that the explanation.
The trick is in this line:
Using this binding you pass a whole object to the independent axis, not just a property.
And after that you can get properties of a bound object in the control template of label:
The
Binding
keyword instead of theTemplateBinding
looks strange, but it is permitted and it works.And there is one remark: the
Url
property must contain thehttp
prefix. It doesn't work withwww
.