Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3590
How to bind a series of XamDataCharts it an ItemsControl
posted

I have a viewmodel that has a list GraphConfig objects that I bind to an ItemsControl. I am trying to generate as much as I can from xaml but I have run into serveral areas that I am not able to use straight databinding. One of the first things I ran into is I was trying to bind the xaxis labelsetting visibility to a property on the GraphConfig object. The problem is that no matter what I put in there I always get the same error: 

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Infragistics.Controls.Charts.XamDataChart', AncestorLevel='1''. BindingExpression:Path=DataContext.IsLast; DataItem=null; target element is 'AxisLabelSettings' (HashCode=12116793); target property is 'Visibility' (type 'Visibility')

I thought the below code would work but it didn't. I also replaced this code with other bindings that do work in the same template and still get the same error.

<ig:AxisLabelSettings Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ig:XamDataChart}}, Path=DataContext.IsLast, Converter={StaticResource BooleanToVisibilityConverter}}" Location="OutsideBottom" />

Here is the template:

<ItemsControl ItemsSource="{Binding Graphs}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ig:XamDock x:Name="XamDataChartContainer1" Margin="0">
<ig:XamDataChart
Margin="0"
Height="200"
CrosshairVisibility="Visible"
CrosshairLineStyle="{StaticResource CrosshairLineStyle}"
VerticalZoomable="False"
VerticalZoombarVisibility="Collapsed"
HorizontalZoomable="False"
HorizontalZoombarVisibility="Collapsed"
Background="Black"
PlotAreaBorderBrush="Black"
PlotAreaBackground="Black"
BorderThickness="0"
PlotAreaBorderThickness="0"
Legend="{Binding ElementName=xmLegend}" >
<behavior:ChartBehaviors.HoveredScatterItems>
<behavior:HoveredScatterItemsBehavior />
</behavior:ChartBehaviors.HoveredScatterItems>
<behavior:ChartBehaviors.HoveredCategoryItems>
<behavior:HoveredCategoryItemsBehavior CategoryOffset="True">
<behavior:HoveredCategoryItemsBehavior.ItemComparer>
<model:CustomDateTimeItemComparer />
</behavior:HoveredCategoryItemsBehavior.ItemComparer>
</behavior:HoveredCategoryItemsBehavior>
</behavior:ChartBehaviors.HoveredCategoryItems>
<behavior:ChartBehaviors.FloatingTooltip>
<behavior:FloatingTooltipBehavior
TooltipTemplate="{StaticResource tooltipTemplate}"
HoveredItems="{Binding Path=(behavior:ChartBehaviors.HoveredCategoryItems).HoveredItems}"/>
</behavior:ChartBehaviors.FloatingTooltip>
<ig:XamDataChart.Axes>
<ig:NumericXAxis x:Name="dateAxis"
Visibility="Visible"
MinimumValue="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.MinDateTime.Ticks}"
MaximumValue="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.MaxDateTime.Ticks}">
<ig:NumericXAxis.Label>
<DataTemplate>
<TextBlock Text="{Binding Path=Item, Converter={StaticResource TicksToDateTime}, ConverterParameter='HH:mm:ss'}" Foreground="White" />
</DataTemplate>
</ig:NumericXAxis.Label>
<ig:NumericXAxis.LabelSettings>
<ig:AxisLabelSettings Visibility="Collapsed" Location="OutsideBottom" />
</ig:NumericXAxis.LabelSettings>
</ig:NumericXAxis>
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
</ig:XamDataChart.Series>
<ig:SyncManager.SyncSettings>
<ig:SyncSettings SyncChannel="syncGroup1" SynchronizeHorizontally="True" SynchronizeVertically="False"/>
</ig:SyncManager.SyncSettings>
</ig:XamDataChart>
<ig:Legend x:Name="xmLegend"
ig:XamDock.Edge="InsideTop"
ig:XamDock.HorizontalDockAlignment="Left"
ig:XamDock.VerticalDockAlignment="Top"
Style="{StaticResource LegendStyle}">
</ig:Legend>
</ig:XamDock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

Will I be able to add series in this method?

Parents Reply Children
No Data