Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF DynamicDataDisplay基于值使用图标图像显示模板化轴标签_C#_Wpf_Xaml - Fatal编程技术网

C# WPF DynamicDataDisplay基于值使用图标图像显示模板化轴标签

C# WPF DynamicDataDisplay基于值使用图标图像显示模板化轴标签,c#,wpf,xaml,C#,Wpf,Xaml,在搜索WPF的开放图表库时,我找到了该库 但是,我找不到一种方法(可能是由于糟糕的文档)来格式化轴标签,它们包含基于值的图像 为什么我需要这个 我目前编写了一个跟踪游戏(GW2)市场价格的工具 这些价格显示为金、银和铜,我根据铜的价值获得价格,我希望垂直轴显示价格 因此,希望有人知道一种为D3的轴标签设置模板的方法。轴包含一个LabelProvider属性。您可以创建自定义标签提供程序,并在重写方法CreateLabels中创建所需的所有控件。多亏Mikhail Brinchuk为我指明了正确的

在搜索WPF的开放图表库时,我找到了该库

但是,我找不到一种方法(可能是由于糟糕的文档)来格式化轴标签,它们包含基于值的图像

为什么我需要这个

我目前编写了一个跟踪游戏(GW2)市场价格的工具

这些价格显示为金、银和铜,我根据铜的价值获得价格,我希望垂直轴显示价格


因此,希望有人知道一种为D3的轴标签设置模板的方法。

轴包含一个LabelProvider属性。您可以创建自定义标签提供程序,并在重写方法CreateLabels中创建所需的所有控件。

多亏Mikhail Brinchuk为我指明了正确的方向。 以下是我提出的解决方案:

<Window x:Class="ChartTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
    xmlns:chart="clr-namespace:ChartTest.Chart"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <chart:MoneyLabelProvider x:Key="MoneyLabelProvider"></chart:MoneyLabelProvider>
</Window.Resources>
<Grid>
    <d3:ChartPlotter x:Name="Plotter">
        <d3:ChartPlotter.VerticalAxis>
            <d3:VerticalIntegerAxis x:Name="Axis" LabelProvider="{StaticResource MoneyLabelProvider}">
            </d3:VerticalIntegerAxis>
         </d3:ChartPlotter.VerticalAxis>

        <d3:ChartPlotter.HorizontalAxis>
            <d3:HorizontalDateTimeAxis x:Name="DateTimeAxis">
            </d3:HorizontalDateTimeAxis>
        </d3:ChartPlotter.HorizontalAxis>
    </d3:ChartPlotter>
</Grid>

公共类MoneyLabelProvider:GenericLabelProvider
{
public override System.Windows.UIElement[]CreateLabels(Microsoft.Research.DynamicDataDisplay.Charts.ITicksInfo ticksInfo)
{
var customElements=新的UIElement[ticksInfo.Ticks.Length];
for(int i=0;i
我在这个链接中有一个非常接近的问题,我想你可以回答我的问题,请帮助
public class MoneyLabelProvider : GenericLabelProvider<int>
{
    public override System.Windows.UIElement[] CreateLabels(Microsoft.Research.DynamicDataDisplay.Charts.ITicksInfo<int> ticksInfo)
    {
        var customElements = new UIElement[ticksInfo.Ticks.Length];

        for (int i = 0; i < customElements.Length; i++)
        {
            var mv = new MoneyView(); // View provides the money style format
            var money = new Money(0, 0, ticksInfo.Ticks[i]); // Data class provides the calculation
            mv.DataContext = money; // Bind the data to the view

            customElements[i] = mv;
        }

        return customElements;
    }
}