0
votes

it's my first post here so, sorry for my mistakes in advance:). Here is my problem: I am trying to build a WPF application using the MVVM pattern and I'm not ALWAYS able to load data in my chart. The only time when it works is when I use the PieSeries. In the all other cases I receive an error. What is strange is that in my designer window is amable to see my chart. Here is my code:

<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>

In the viewModel I have among other things:

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));
}

Image with the error http://imgur.com/hsuC6Yd

Thank you in advance.

1

1 Answers

0
votes

It seems that the problem is in the WPF Toolkit. The bindings above were correct. The problem was that I had specified the xml:lang in my window other than en-US and because of that the application crashed.

For more details please see here and here