bon,
alors le code a marché, j' ai modifié le c#:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| private Panel ChartArea
{
get
{
if (chartArea == null)
{
chartArea = GetLogicalChildrenBreadthFirst(graphgeneral).Where(element => element.Name.Equals("ChartArea")).FirstOrDefault() as Panel;
}
return chartArea;
}
}
private ScrollViewer ScrollArea
{
get
{
if (scrollArea == null)
{
scrollArea = GetLogicalChildrenBreadthFirst(graphgeneral).Where(element => element.Name.Equals("ScrollArea")).FirstOrDefault() as ScrollViewer;
}
return scrollArea;
}
}
private IEnumerable<FrameworkElement> GetLogicalChildrenBreadthFirst(FrameworkElement parent)
{
Debug.Assert(parent != null, "The parent cannot be null.");
Queue<FrameworkElement> queue =
new Queue<FrameworkElement>(GetVisualChildren(parent).OfType<FrameworkElement>());
while (queue.Count > 0)
{
FrameworkElement element = queue.Dequeue();
yield return element;
foreach (FrameworkElement visualChild in GetVisualChildren(element).OfType<FrameworkElement>())
{
queue.Enqueue(visualChild);
}
}
}
private IEnumerable<DependencyObject> GetVisualChildren(DependencyObject parent)
{
Debug.Assert(parent != null, "The parent cannot be null.");
int childCount = VisualTreeHelper.GetChildrenCount(parent);
for (int counter = 0; counter < childCount; counter++)
{
yield return VisualTreeHelper.GetChild(parent, counter);
}
}
private void nombre_MouseWheel(object sender, MouseWheelEventArgs e)
{
Debug.Assert(ChartArea != null && ScrollArea != null, "Zoom should not be called before layout has occurred");
double test = chartArea.Width;
chartArea.Width = chartArea.Height = test + e.Delta;
} |
Le problème c' est que je récupere l' item sélectionné dans le graphique pour en créer un autre:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <Grid.Resources>
<local:ElementToList x:Key="ElementToList" />
</Grid.Resources>
<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:Population, CreateList=true}" Height="0" LoadedData="populationDomainDataSource_LoadedData_1" Name="populationDomainDataSource" QueryName="GetPopulationQuery" Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:PopulationContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<toolkit:Chart x:Name="graphgeneral" Template="{StaticResource ZoomChartTemplate}" MouseWheel="nombre_MouseWheel" MouseEnter="graphgeneral_MouseEnter">
<toolkit:ColumnSeries x:Name="nombre" Title="Population" ItemsSource="{Binding ElementName=populationDomainDataSource, Path=Data}" DependentValueBinding="{Binding Path=Nombre}" IndependentValueBinding="{Binding Path=Lieu}" IsSelectionEnabled="True" ScrollViewer.VerticalScrollBarVisibility="Auto" AnimationSequence="FirstToLast" SelectionChanged="SelectionChanged" />
<toolkit:LineSeries x:Name="enfant" Title="Enfant" ItemsSource="{Binding ElementName=populationDomainDataSource, Path=Data}" DependentValueBinding="{Binding Path=Enfant}" IndependentValueBinding="{Binding Path=Lieu}" IsSelectionEnabled="True" SelectionChanged="SelectionChanged"/>
</toolkit:Chart>
<toolkit:Chart x:Name="graphville" Visibility="Collapsed" MouseLeftButtonDown="graphville_MouseLeftButtonDown">
<toolkit:PieSeries x:Name="ville"
ItemsSource="{Binding ElementName=nombre, Path=SelectedItem, Converter={StaticResource ElementToList}}"
IndependentValueBinding="{Binding Path=Name}"
DependentValueBinding="{Binding Path=Nombre}"/>
</toolkit:Chart> |
dès que je rajoute:
Template="{StaticResource ZoomChartTemplate}"
a mon graphique, le deuxième ne récupère pas les valeurs,
je ne comprend pas pourquoi c' est modifié.
Merci.
Partager