Коллеги, пытаюсь нарисовать график в WPF Toolkit, биндя его к колекции ObservableCollection Не могу понять почему не рисует... такая схема в гридах работает отллично... Буду признателен за помощь! Код | public class Data { public Data(string name, int value) { Name = name; Value = value; }
public string Name { get; set; } public int Value { get; set; } }
class Model : ObservableCollection<Data> { }
|
Код | public partial class WindowChartSample : Window { public WindowChartSample() { InitializeComponent(); Model Mdl = (Model)this.FindResource("model"); Mdl.Add(new Data("First", 70)); Mdl.Add(new Data("Second", 20)); } }
|
Код | <Window x:Class="WpfApplicationChart.WindowChartSample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WindowChartSample" Height="327" Width="505" xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:WpfApplicationChart="clr-namespace:WpfApplicationChart"> <Window.Resources> <WpfApplicationChart:Model x:Key="model"/> </Window.Resources> <Grid DataContext="{Binding Source={StaticResource model}}"> <chartingToolkit:Chart> <chartingToolkit:PieSeries ItemsSource="{Binding Path=Data}" DependentValuePath="Value IndependentValuePath="Name" /> </chartingToolkit:Chart> </Grid> </Window>
|
|