【问题标题】:Dynamic Data Display Chart with legend checkbox (WPF)带有图例复选框的动态数据显示图表 (WPF)
【发布时间】:2013-04-30 17:36:45
【问题描述】:

我正在尝试在下面的链接 http://research.microsoft.com/en-us/um/cambridge/projects/ddd/d3isdk/ 中的 Miscellanous 下重新创建名为“Line Graph legend”的示例

我使用的是 WPF 而不是 silverligth,并且在获取以下 XAML 部分的引用时遇到了问题。

 <d3:Chart.LegendContent>
    <d3:LegendItemsPanel>
        <d3:LegendItemsPanel.Resources>
            <DataTemplate x:Key="Microsoft.Research.DynamicDataDisplay.LineGraph">
                <StackPanel Orientation="Horizontal">
                    <CheckBox IsChecked="{Binding Path=Visibility, Converter={StaticResource VisibilityToCheckedConverter}, Mode=TwoWay}"/>
                    <Line Width="15" Height="15" X1="0" Y1="0" X2="15" Y2="15" Stroke="{Binding Path=Stroke}" StrokeThickness="2"/>
                    <TextBlock Margin="5,0,0,0" Text="{Binding Path=Description}"/>
                </StackPanel>
            </DataTemplate>
        </d3:LegendItemsPanel.Resources>
    </d3:LegendItemsPanel>
</d3:Chart.LegendContent>

谢谢

【问题讨论】:

  • 是否可以在 wpf 桌面应用程序中使用 silverlight 控件?

标签: wpf legend dynamic-data-display


【解决方案1】:

在开始使用 D3 时,我遇到了同样的困惑。据我了解,它最初是为 WPF 开发的,然后用作在 Silverlight 中构建相同功能的跳板。所以你在网上看到的例子有一些区别和一些额外的功能是你在 WPF 版本中看不到的。

首先,WPF 版本中不存在“图表”类。您更有可能在图表中使用“ChartPlotter”。与“Legend”和“LineLegendItem”相同,而不是“LegendContent”和“LegendItemsPanel”。这可能是你想要去的地方:

<d3:ChartPlotter>
    <d3:Legend>
        <d3:LineLegendItem>
            <d3:LineLegendItem.Resources>
                <DataTemplate StackPanel with checkbox>
            </d3:LineLegendItem.Resources>
        </d3:LineLegendItem>
    </d3:Legend>
</d3:ChartPlotter>

我没有亲自使用过这些类,所以我没有第一手的知识证明这与 Silverlight 示例相匹配,但我希望这足以让你开始尝试。

我强烈建议您查看下载on the official D3 page 中的示例。我最近发现您可以查看他们的示例背后的代码,这很烦人地不包含在下载中,online here。 (Stable>v0.3.1>src>Samples,找到你要检查的sample)。

我没有看到任何有您在图例中具有复选框的确切示例,但是一旦您开始访问正确的类,您的方法似乎应该可以工作。

另外,我假设您使用以下行而不是 Silverlight 行来引用库:

xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"

【讨论】:

【解决方案2】:

您需要在此处使用示例: https://github.com/Microsoft/InteractiveDataDisplay.WPF/tree/master/samples/LineGraphSample

交互式数据显示是 D3 的延续(无论如何都是其中之一)。不过,有些 C# 可能会有所不同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 2016-10-30
    • 1970-01-01
    • 2021-01-05
    相关资源
    最近更新 更多