在爲WPF搜索打開的圖表庫時,我找到了DynamicDataDisplay庫。WPF DynamicDataDisplay基於值的帶圖標圖像的模板軸標籤
但是我無法找到一種方法(可能是由於文檔較差),以便根據值格式化包含圖像的軸標籤。
爲什麼我需要這個?
我目前正在編寫一個跟蹤遊戲市場價格(GW2)的工具。
這些價格顯示爲金,銀和銅,我根據銅價得到價格,我希望垂直軸顯示價格。
所以希望有人知道一種方法來模擬D3的軸標籤。
在爲WPF搜索打開的圖表庫時,我找到了DynamicDataDisplay庫。WPF DynamicDataDisplay基於值的帶圖標圖像的模板軸標籤
但是我無法找到一種方法(可能是由於文檔較差),以便根據值格式化包含圖像的軸標籤。
爲什麼我需要這個?
我目前正在編寫一個跟蹤遊戲市場價格(GW2)的工具。
這些價格顯示爲金,銀和銅,我根據銅價得到價格,我希望垂直軸顯示價格。
所以希望有人知道一種方法來模擬D3的軸標籤。
軸包含一個LabelProvider屬性。您可以創建自定義標籤提供程序,並使用重寫方法CreateLabels創建所需的所有控件。
感謝米哈伊爾布林丘克指引我在正確的方向。 這裏是我想出瞭解決方案:
<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>
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;
}
}
我在這個環節緊密的問題,我想你可以回答我的問題,請大家幫忙http://stackoverflow.com/問題/ 14335790 /如何使用的-的UIElement-createlabels法合numericlabelproviderbase級到 –