【问题标题】:Binding in WPF Toolkit on Chart Series在图表系列上的 WPF 工具包中绑定
【发布时间】:2013-06-12 05:53:53
【问题描述】:

这是我在这里的第一篇文章,抱歉我的错误提前:)。这是我的问题:我正在尝试使用 MVVM 模式构建 WPF 应用程序,但我并不总是能够在我的图表中加载数据。它唯一有效的时候是我使用 PieSeries 的时候。在所有其他情况下,我收到一个错误。奇怪的是,在我的设计器窗口中可以看到我的图表。 这是我的代码:

<Border Background="White" BorderThickness="2" BorderBrush="Black" Grid.Column="1">
    <!--ContentPresenter Content="{Binding Path=FormHost}">
    </ContentPresenter-->
    <Grid>
        <chart:Chart Name="chart1">                                   
            <chart:Chart.Series>
                <chart:PieSeries Name="series1" ItemsSource="{Binding ChartItems}"
                                 IndependentValueBinding="{Binding Path=Name}"
                                 DependentValueBinding="{Binding Path=Value}"/>
            </chart:Chart.Series>
        </chart:Chart>
    </Grid>
</Border>

在 viewModel 中我有其他东西:

private ObservableCollection<ChartElement> chartItems; 
public MainWindowViewModel()
{                       
    chartItems = new ObservableCollection<ChartElement>();

    chartItems.Add(new ChartElement("da011111111111", 3));
    chartItems.Add(new ChartElement("adas111111", 490));
    chartItems.Add(new ChartElement("adas111111", 341));
    chartItems.Add(new ChartElement("adas111111", 413));
    chartItems.Add(new ChartElement("adas111111", 143));
}

带有错误的图像

提前谢谢你。

【问题讨论】:

    标签: wpf binding charts wpftoolkit


    【解决方案1】:

    似乎问题出在 WPF Toolkit 中。上面的绑定是正确的。问题是我在我的窗口中指定了xml:lang 而不是en-US,因此应用程序崩溃了。

    更多详情请查看herehere

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 2012-02-28
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      相关资源
      最近更新 更多