I need to create a datagrid whose column should be bound to the piechart in such a manner that when I change the value of the column the piechart should get updated.
I want the datagrid should have two columns and should populate these fruit collection values.Also most importantly the datagrid should have only a single editable column i.e. SHARE and on changing the value under this column should automatically gets reflected in the piechart.For that the column SHARE must be binded with the piechart.
Please help me with complete code.
Below is my datagrid code.
<DataGrid x:Name="dataGrid2" Padding="3" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" ScrollViewer.HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" Width="301" Margin="0,10,10,10" Grid.ColumnSpan="2">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="Blue"/>
</Style>
</DataGrid.Resources>
</DataGrid>
Also the piechart code.
<DVC:Chart HorizontalAlignment="Center" VerticalAlignment="Bottom" Canvas.Top="80" Canvas.Left="10" Name="mcChart"
Background="White" Height="204" Width="754" Grid.Row="2" Grid.ColumnSpan="3" Margin="6,0,0,0">
<DVC:Chart.Series>
<DVC:PieSeries Title="Experience"
ItemsSource="{StaticResource FruitCollection}"
IndependentValueBinding="{Binding Path=Name}"
DependentValueBinding="{Binding Path=Share}">
</DVC:PieSeries>
</DVC:Chart.Series>
</DVC:Chart>
As you can see what I have tried that to create the pie chart and the piechart is taking its values from 'Share' property.
The Dependent Value Binding is bonded to Share property and taking the value from fruitcollection.
class FruitCollection : System.Collections.ObjectModel.Collection<Fruit>
{
public FruitCollection()
{
Add(new Fruit { Name ="0-15", Share ="1000000"});
Add(new Fruit { Name ="15-30", Share = "300000" });
Add(new Fruit { Name ="30-45", Share = "200000" });
Add(new Fruit { Name = "45-60", Share = "90000" });
}
}
What I have tried:
I searched in google and could find a piechart code which was bounded to a fruitcollection.I need to modify it as per the requirements mentioned above.
Please help!